Skip to content

Comments

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

Merged
ElizabethSamuel-MSFT merged 6 commits intomainfrom
eliz-word-pages
Apr 23, 2025
Merged

[Word] Add snippets for APIs re pages, panes, windows#974
ElizabethSamuel-MSFT merged 6 commits intomainfrom
eliz-word-pages

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

ElizabethSamuel-MSFT and others added 2 commits April 23, 2025 09:00
Co-authored-by: Alex Jerabek <38896772+AlexJerabek@users.noreply.github.com>
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants