How to Find Relative Hyperlink Fields Programmatically in Word
Question details
The user needs to programmatically retrieve the original relative path of a hyperlink in a Word document, bypassing the default absolute path returned by the Hyperlink.Address property.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Developing a VBA macro or C# application to extract raw hyperlink paths from a Word document where the default API resolves them to absolute paths.
- Observed behavior
- The Hyperlink.Address property returns a fully resolved absolute path even when the hyperlink was inserted as a relative link. The original relative link is visible via Alt+F9 but not directly accessible through the Address property.
Ensure your Word document contains relative hyperlinks and your VBA or C# development environment is properly configured with the Word Object Model references.
Extract Raw Link Text from the Field.Code Property
Use this method to retrieve the exact relative path as it was typed into the document, bypassing the automatic absolute path resolution of the Hyperlink object.
In Microsoft Word, Hyperlink objects are also Field objects. Because recent updates to the Word Object Model cause the Hyperlink.Address property to return a fully resolved absolute path, the most reliable workaround is to inspect the underlying Field object.
By accessing the Field.Code property, you can read the raw HYPERLINK instruction string and parse out the original relative path exactly as it was entered.
In your VBA or C# code, write a loop to iterate through the Document.Fields collection instead of the Document.Hyperlinks collection.
Check the Type property of each Field object. You are looking for fields where the type is equal to wdFieldHyperlink (or the numeric equivalent 88).
Access the Field.Code.Text property. This will return the raw field instruction, such as ' HYPERLINK "../relative/path/file.docx" '.
Use standard string manipulation functions (like Split, Mid, or Regex in C#) to extract the text located between the quotation marks in the Field.Code.Text string. This extracted string is your original relative hyperlink.

Switch to WPS Office for Reliable Document Editing
If you are encountering frustrating API changes or unexpected behaviors in Microsoft Word, consider switching to WPS Office. It provides a lightweight, highly compatible environment for document editing with robust support for macros and Microsoft Office file formats.
- 1. Download and Install WPS Office: Get WPS Office for free from the official website and easily install it on your computer.
- 2. Open Your Word Documents: Launch WPS Writer and open your existing .docx or .docm files directly without worrying about file conversion.
- 3. Continue Editing Seamlessly: Enjoy a familiar interface and robust compatibility to handle all your document formatting and automation needs.

Frequently Asked Questions
Why does Hyperlink.Address return an absolute path for relative links?
In newer versions of Microsoft Word, the Hyperlink.Address property automatically resolves relative links to absolute paths based on the document's save location or the designated hyperlink base. To get the original user input, you must read the underlying field code instead.
How do I view the raw field codes manually in Word?
You can toggle the display of field codes by pressing Alt+F9 on your keyboard. This reveals the underlying HYPERLINK instruction directly in the document text, allowing you to see the exact relative path.
Does this workaround apply to both VBA and C# Interop?
Yes, the Field.Code property is exposed through the Word Object Model and is fully accessible in both VBA and C#. You can iterate through the Document.Fields collection in either language to extract the raw text.




