logo
search
Others

How to Get Word Bookmark Range Start and End Positions with Office.js

Phi Hung VoPhi Hung Vo Sep 25, 2026 869 views

Question details

The user needs to retrieve the start, end, and reference page positions of a bookmark range using the Word JavaScript API.

Getting Word Bookmark Range Start and End Positions via Office.js
Product
Microsoft Word (Office.js)
Device & OS
not provided
Scenario
Developing a Word add-in using the Office.js API and manipulating bookmarks within a document.
Observed behavior
The user is calling getBookmarkRangeOrNullObject but needs the exact properties or methods to extract the start and end positions, including the page reference.
Before you start

Ensure you are familiar with the asynchronous nature of the Word JavaScript API and have your add-in development environment open.

Solution 1Recommended

Seek Developer Support on Stack Overflow

Since Office.js is a specialized Microsoft development framework, Stack Overflow is the officially recommended platform for API-specific troubleshooting.

The Word JavaScript API handles document positioning differently than older COM/VBA models. Extracting absolute page numbers or index-based start/end positions often requires specific workarounds, as Office.js abstracts the document into flow content.

1
Prepare your code snippet

Gather the specific JavaScript or TypeScript code where you are calling context.document.getBookmarkRangeOrNullObject('BookmarkName').

2
Identify your environment details

Note down your Word API requirement set version (e.g., WordApi 1.3) and the host platform (Word on the Web, Windows, or Mac) where the issue occurs.

3
Post your question with the correct tags

Submit your detailed question to Stack Overflow. Ensure you apply the 'office-js' and 'ms-word' tags so that developers familiar with the Word API can locate and answer your query.

Seek Developer Support on Stack Overflow
Microsoft Support: Microsoft's product engineering team actively monitors the 'office-js' tag on Stack Overflow to provide official guidance on supported range properties.
Free Microsoft Office alternative

Try WPS Office for Your Document Needs

If you are encountering limitations with Microsoft Office or its add-in ecosystem, consider switching to WPS Office. It provides a lightweight, highly compatible alternative for viewing, editing, and managing Word documents seamlessly.

  1. 1. Download WPS Office: Visit the official WPS website and download the free installer for your operating system.
  2. 2. Install and Launch: Run the installer, follow the simple on-screen instructions, and launch WPS Writer.
  3. 3. Open Your Word Documents: Drag and drop your existing .docx files into WPS Writer to continue editing with full formatting compatibility.
Free and lightweight Office suite with low system requirementsExcellent format compatibility with Microsoft Word (.docx, .doc)Familiar user interface requiring no learning curveSeamless migration of your existing documents and bookmarks
microsoft office alternative - wps office

Frequently Asked Questions

Can I get the exact page number of a bookmark in Office.js?

Office.js does not provide a direct property for absolute page numbers on ranges because Word documents dynamically paginate based on the viewing environment. You may need to explore API workarounds or rely on text-based markers instead of absolute pagination.

What does getBookmarkRangeOrNullObject do?

It is a method in the Word JavaScript API that returns a Range object representing a specific bookmark. If the bookmark does not exist in the document, it returns a null object, preventing your add-in from crashing due to an undefined reference.

Where is the best place to ask Office.js API questions?

Microsoft recommends using Stack Overflow with the 'office-js' tag. This ensures your question reaches the developer community and Microsoft engineers who specialize in Office extensibility.