How to Synchronize Word Add-in Bookmarks and Underline Formatting
Question details
The user needs to keep text underline formatting and bookmarks synchronized when users type at the end of a bookmarked range injected via a Word JavaScript add-in and OOXML.

- Product
- Microsoft Word (JavaScript API)
- Device & OS
- not provided
- Scenario
- Developing a Word JavaScript add-in that applies underline formatting and inserts text into a bookmark via OOXML.
- Observed behavior
- When a user types at the end of the bookmarked text, the underline formatting extends to the new text, but the bookmark range does not expand, leading to inconsistent formatting when the bookmark is later removed.
Ensure you have access to your Word add-in source code, a text editor, and a basic understanding of OOXML (Office Open XML) structures before modifying document behaviors.
Consult Microsoft Q&A for Office Development Support
Since bookmark expansion and OOXML behavior in JavaScript add-ins require advanced API handling, seeking specialized help from the Office Development community is the most effective approach.
Microsoft Word handles character formatting runs and bookmark ranges differently at the XML level. Because this is a specific limitation or nuance of the Word JavaScript API and OOXML rendering engine, direct developer support is highly recommended.
Open your web browser and go to the official Microsoft Q&A platform where developer issues are actively tracked.
When creating your post, ensure you include the 'Office Development' and 'Word' tags so that JavaScript add-in specialists and Microsoft engineers can easily find your question.
Include your specific OOXML snippet and the exact JavaScript API calls you are using to insert the bookmark and apply the underline formatting to help experts diagnose the desync.

Programmatically Update the Bookmark Range on Edit
Use document editing event listeners to detect changes and manually expand the bookmark to cover the newly typed underlined text.
Looking for a Lighter, Highly Compatible Office Suite?
If complex add-in behaviors and formatting desyncs are slowing down your workflow, try WPS Office. It provides a lightweight, highly compatible alternative for everyday document editing, ensuring your formatting stays intact without the heavy overhead.
- 1. Download WPS Office: Visit the official WPS website and download the free installation package for Windows, Mac, or Linux.
- 2. Install the Software: Run the downloaded installer and follow the simple on-screen instructions to set up the suite.
- 3. Open Your Document: Launch WPS Writer and open your .docx file to edit text and formatting with complete compatibility.

Frequently Asked Questions
Why does underline formatting extend but the bookmark does not in Word?
In OOXML, character formatting like underlines automatically applies to newly typed text adjacent to it as part of the same 'run'. However, a bookmark is defined by static start and end tags in the XML, which do not automatically expand unless explicitly configured to enclose the new keystrokes.
Can I fix bookmark expansion issues using only OOXML?
It is very difficult to fix dynamic typing behaviors using only static OOXML insertion. You typically need to utilize the Word JavaScript API event handlers to monitor text input and dynamically adjust the bookmark boundaries after the user types.
Where is the best place to get help with Word JS Add-in development?
The Microsoft Q&A platform, specifically under the 'Office Development' tag, is the best place to interact with Microsoft engineers and community experts regarding JavaScript API and OOXML structure issues.




