How to set the vertical scroll percentage on the active document

G6574567 0 Reputation points
2025-12-15T16:29:47.4033333+00:00

I'm working on a Word add-in using the preview version of the Office API and I'm trying to programmatically scroll the page, which seems to be possible based on the docs.

I'm trying to do something like this:

await Word.run(async (context) => {
  const win = context.document.activeWindow;
  win.set({ verticalPercentScrolled: 75 })
  return context.sync();
})

So far I haven't been able to get this to work. Am I missing something here?

Microsoft 365 and Office | Development | Office JavaScript API
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Q&A Assist
    2025-12-15T16:30:03.5566667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    To set the vertical scroll percentage on the active document in a Word add-in using the Office JavaScript API, you need to ensure that you are using the correct method to set the verticalPercentScrolled property. However, it appears that the set method is not directly available for the Word.Window object. Instead, you should use the window.update method to set properties like verticalPercentScrolled. Here’s an example of how to do this:

    await Word.run(async (context) => {
      const win = context.document.activeWindow;
      win.set({ verticalPercentScrolled: 75 }); // This line needs to be corrected
      await context.sync();
    });
    

    The correct approach would be to use the window.set method as shown, but ensure that you are calling context.sync() after setting the property to apply the changes. If you are still facing issues, please check if the API version you are using supports this property and method as expected.


    References:

    0 comments No comments

  2. Kha-N 5,760 Reputation points Microsoft External Staff Moderator
    2025-12-16T00:03:10.01+00:00

    Hi @G6574567,

    Welcome to Microsoft Q&A forum, and thank you so much for reaching out to us.

    Based on your description, may I verify whether you are using Word for the Web or Word for desktop?

    I checked on the document you provided, and from my research, the vertical percentage scroll feature is available only in Word JavaScript API 1.4:

    User's image

    User's image

    I also checked the same API in Preview, and it does not appear to be available there:

    User's image

    This suggests the feature may not work when using the Preview API.

    Therefore, if possible, I recommend switching your add-in to use Word API 1.4 to verify whether it resolves the issue. Note that Word API 1.4 is supported in Word desktop app only, according to this Microsoft documentation.

    User's image

    I hope this helps.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".     

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.