Share via

Find relative hyperlink fields programmatically

Anonymous
2024-01-12T18:11:31+00:00

Split from this thread.

Thanks. ALT+F9 works great.

I have a document with a single relative link. Verified by using ALT+F9.

Is there a way I can "programmatically" view the links in a document.

I have tried using Word VBA but whenI look at the address field for the relative link, it shows an absolute address.

When I use C++ and the Word Document interfaces to look at the address field for the relative link, it shows an absolute address.

Daniel

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

5 answers

Sort by: Most helpful
  1. Anonymous
    2024-02-20T14:22:29+00:00

    How do you "extract the raw link from the Field.Code property of a Hyperlink?

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2024-02-08T02:20:49+00:00

    Thanks.

    I've not worked with "Fields".

    How do I "extract the raw link text from the Field.Code property"?

    Could you reply with a code fragment?

    I am implementing a program in C# but am familiar with VBA. So code in either language is great.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2024-02-06T18:59:12+00:00

    This used to be available via the Hyperlink.Address property in VBA. At some point the behavior changed so it always returns a fully resolved path, even for relative links. I know this because I recently had to fix a macro was crippled by the change.

    The workaround I settled on was extracting the raw link text from the Field.Code property. Hyperlink objects are also Field objects.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2024-01-12T21:52:12+00:00

    Thanks ... again ... for quick reply

    I did the previous reply in the old thread so that who sees the "programmatic" query has some context.

    My project is a reasonably sized manual written in Word with lots of relative links. I have a C++ app I wrote that creates pdfs for all the Word files in case the reader doesn't have Word. That app also verifies all the links satisfy various criteria I have set. One is that the appropriate links are relative and "valid" so that the manual can be installed anywhere, i.e. the target of relative link is in the deliverable package.

    Daniel

    Was this answer helpful?

    0 comments No comments
  5. John Korchok 232.8K Reputation points Volunteer Moderator
    2024-01-12T18:15:36+00:00

    I've split your new question to a new thread to ensure it receives attention.

    Was this answer helpful?

    0 comments No comments