How to Extract PDF Text Coordinates Using MS Access VBA and Acrobat API
Question details
A developer needs a programmatic way to locate specific text in a PDF and retrieve its precise X and Y coordinates.

- Product
- Adobe Acrobat / MS Access VBA
- Device & OS
- not provided
- Scenario
- Developing a script in MS Access VBA using the Adobe Acrobat Type Library to process PDF documents and extract text positions.
- Observed behavior
- Needs the specific API objects and methods to return the bounding box coordinates of found strings.
Ensure that you have Adobe Acrobat Professional or Standard installed, as the free Adobe Reader does not support the Interapplication Communication (IAC) API required for programmatic manipulation via VBA. You must also add the Adobe Acrobat Type Library reference in your MS Access VBA editor before executing the code.
Extract Coordinates Using Acrobat IAC API and JSObject
Use Acrobat's Interapplication Communication (IAC) to bridge VBA and Acrobat JavaScript, allowing the retrieval of coordinate objects via the getPageNthWordRects() method.
The Acrobat API exposes Acrobat JavaScript functionalities through the JSObject. By creating instances of AcroPDDoc and using JSObject, you can execute JavaScript functions directly from Access VBA to extract precise text bounding boxes.
Open your MS Access VBA Editor by pressing Alt + F11. Navigate to Tools > References, scroll down, and check the box for 'Adobe Acrobat x.x Type Library'.
Declare and instantiate your AcroApp, AcroPDDoc, and AcroAVDoc objects in your VBA script to open the target PDF file in the background.
Retrieve the GetJSObject property from your active AcroPDDoc instance. This object acts as a bridge to execute Acrobat JavaScript methods natively from VBA.
Loop through the document pages and words. Use the JSObject's getPageNthWordRects() method on the matched text to get an array containing the bounding box coordinates (left, top, right, bottom).

Find Coordinates Manually Using the Measure Tool
If you only need to find coordinates for a few specific items without writing VBA code, you can use the built-in Measure tool in Acrobat.
Looking for a Lightweight Office Suite with Built-in PDF Tools?
While advanced VBA scripting for PDF coordinates requires specific Adobe APIs, WPS Office provides a comprehensive, free alternative to Microsoft Office with a powerful built-in PDF editor. It seamlessly handles Word, Excel, PowerPoint, and PDF files in one lightweight application.
- 1. Download WPS Office: Visit the official WPS website and download the free installation package for your operating system.
- 2. Install the Software: Run the installer and follow the simple on-screen instructions to set up WPS Office on your device.
- 3. Open Your Documents: Launch WPS Office to seamlessly open, edit, and manage your Office and PDF files in one unified workspace.

Frequently Asked Questions
What unit of measurement does the Acrobat API use for PDF coordinates?
The Acrobat API typically uses points (1/72 of an inch) as the standard unit of measurement. The origin point (0,0) is usually located at the bottom-left corner of the PDF page.
Can I use Adobe Reader to extract PDF coordinates via VBA?
No, the free Adobe Reader does not support the Interapplication Communication (IAC) API required for this level of programmatic access. You must have Adobe Acrobat Standard or Professional installed.
Why does getPageNthWordRects return an array instead of a single coordinate?
A word in a PDF is represented by a bounding box rather than a single point. The method returns an array containing four values (left, top, right, bottom) that define the rectangular area the word occupies on the page.
Is it possible to find coordinates of scanned text using this VBA method?
No, the Acrobat API can only retrieve coordinates for actual text elements. If the PDF is a scanned image, you must first perform Optical Character Recognition (OCR) to convert the image into selectable text before running your VBA script.




