Find PDF Text Coordinates with Excel VBA and Acrobat
Question details
Find the position of an invoice number or other text on PDF pages so it can be used to name split files.

- Product
- Microsoft Excel VBA and Adobe Acrobat
- Device & OS
- not provided
- Scenario
- An Excel VBA user is processing a PDF whose invoice numbers appear in a consistent location on each page.
- Observed behavior
- The user needs to identify text at the expected page position and use its value as the filename for each split PDF.
Check that you can select the invoice number as text in the PDF; scanned pages may need OCR first. For Excel VBA integration, use a supported Windows installation of Adobe Acrobat and confirm that it can open the PDF.
Retrieve PDF word coordinates through Acrobat JavaScript
Use Acrobat's word and quadrilateral methods to identify text in the invoice-number area before splitting and naming pages.
Acrobat's getPageNthWordQuads method returns the quadrilaterals covering a word, rather than a single X-Y point. Compare those coordinates with the expected invoice-number area; account for page size and rotation when defining that area.
Excel VBA can access Acrobat's JavaScript object through Acrobat's COM interface on Windows. Adobe Acrobat Reader alone does not provide the full Acrobat automation needed for this workflow.
In Excel, open the VBA editor with Alt+F11. Create an AcroExch.PDDoc object, call its Open method with the PDF path, and obtain its JavaScript object with GetJSObject.
Use the JavaScript object's getPageNumWords(pageIndex) to get the word count, then loop through the words with getPageNthWord(pageIndex, wordIndex, false). Page and word indexes start at zero.
For each candidate word, call getPageNthWordQuads(pageIndex, wordIndex) and compare the returned coordinates with the invoice-number region. If the number spans multiple words, collect the relevant adjacent words.
Use the matched invoice number to build a valid filename, removing characters not allowed by your file system. Extract each page with an available Acrobat page-extraction workflow and save it under that name; test any automated saving against Acrobat's security restrictions.

Work with spreadsheets and PDFs in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for opening spreadsheets and viewing PDFs. It makes moving common Office files straightforward, but it does not replace the Acrobat JavaScript and VBA coordinate workflow described above.

Frequently Asked Questions
Can Excel VBA find PDF text coordinates by itself?
Excel VBA does not provide Acrobat's PDF word-coordinate methods by itself. On Windows, use Acrobat's COM interface to open the PDF and GetJSObject to access Acrobat JavaScript methods.
What does getPageNthWordQuads return?
It returns quadrilaterals describing the area occupied by a specified word on a page. Use getPageNthWord to read the word and compare its quadrilaterals with the region you want to inspect.
What if the invoice number is in a scanned PDF?
If you cannot select the number as text, run OCR on the page first. Then check that Acrobat can identify the recognized words before using the word and coordinate methods.
Can the extracted invoice number be used directly as a filename?
Yes, after checking that the correct text was found and removing characters that your file system does not allow. Saving extracted pages also depends on Acrobat's permissions and security restrictions.




