External hyperlinks generated with RPE 1.2.1 and newer do not work from Word (Ctrl+Click) as the address is prefixed with a “#”. This is a defect in RPE and and until the defet is fixed a solution is to use a post processing macro to identify and correct the hyperlinks.
Public Sub fixLinks() Dim lnk As Hyperlink ' RPE generated links are empty and the link is stored in the sub-address field For Each lnk In ActiveDocument.Hyperlinks If Len(lnk.address) = 0 And InStr(lnk.SubAddress, "http") = 1 Then lnk.address = lnk.SubAddress End If Next End Sub
Should it be “RPE 1.2.1 and later”?
Good point, thanks Prasad.
(sorry, new to replying to your blog but following it since some time and maybe stupid question)
How/where do you implement this post-processing code? Is it in the .dot file used for stylesheet or somewhere in RPE template?
How do you secure automatic run of post-processing macro?
Thx for all your excellent posts, I’ll reply on several on them gradually as I have feedback and questions (using RPE with Focal Point)
Welcome to the ranks of commenters of this blog and thanks for your feedback and questions.
On the macro topic:
– the code goes indeed in the stylesheet used for the Word output and not in the template
– to have the macro executed automatically at the end of the docgen you need to:
a. specify the stylesheet for the Word output
b. enter the name of the macro ( in this case fixLinks) in the “macro” property of the Word output
See this for more details: http://www-01.ibm.com/support/docview.wss?uid=swg21395685
Thx for good explanations and the link, Dragos!
This will really come in handy. We can also include “file” apart from “http”.