PDA

View Full Version : WORD VBA Hyperlinks refuse to stay relative and become absolute when saved.



WallyZ
08-17-2015, 08:57 PM
I have the following VBA code to update a single link that is using a relative address but when the document is saved the address becomes absolute.

I have debugged the code and confirmed that "address" is a relative path.


Sub UpdateLink(address as string)
ChangeFileOpenDirectory ActiveDocument.Path
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, address:=address, SubAddress:="", ScreenTip:="", TextToDisplay:="Link"
End Sub

I have checked Options->Advanced->Web Options->Update Links on Save = Ticked.

When I manually check (edit) each created hyperlink they appear to be relative (until the document is saved).

This instant the document is saved the hyperlinks become absolute.

Also once I have created one link programatically in the document any links manually created by the user also become absolute!

Any ideas what I'm doing wrong?

Walter

WallyZ
08-17-2015, 08:58 PM
It appears that changing the :

Options->Advanced->Web Options->Update Links on Save = Unticked.

Fixes the problem.