Skip to content

[Word] Add snippets for APIs re pages, panes, windows #974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 23, 2025

Conversation

ElizabethSamuel-MSFT
Copy link
Contributor

Will do object mapping later


const pages: Word.PageCollection = rangeOfParagraph.pages;
pages.load();
await context.sync();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need three roundtrips to the document before even getting to the API in question? If so, that seems like a product flaw.

for (let i = 0; i < pages.items.length; i++) {
let page = pages.items[i];
page.load();
await context.sync();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid doing load/sync in a loop. It's a bad pattern. This article has some tips to avoid that: https://learn.microsoft.com/en-us/office/dev/add-ins/concepts/correlated-objects-pattern

Copy link
Collaborator

@AlexJerabek AlexJerabek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ElizabethSamuel-MSFT ElizabethSamuel-MSFT merged commit 4011ea0 into main Apr 23, 2025
1 check passed
@ElizabethSamuel-MSFT ElizabethSamuel-MSFT deleted the eliz-word-pages branch April 23, 2025 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants