Email this Page Log Support Call Send Feedback Print

Previous Topic

Next Topic

Book Contents

Book Index

Creating Clickable URL Links When Publishing to Word

From time to time, we get asked how to to avoid the repetition of URLs in the published Word output - for example, the word ouptut might look something like: http://www.author-it.com (http://www.author-it.com)

This is the correct behaviour - because the anchor text (the text with the link applied to it) is a URL.

Why? Because a cross reference is made up of two parts :

  1. the anchor text (which appears as regular text with the hotspot style applied)

    -and-

  2. the actual cross reference (such as the page number or the URL).

This means that when you apply a cross reference to a URL you will get the URL twice.

To avoid the repetition you need to either:

  1. adjust the text that has the link applied.

    For example using something like: visit our website (where the text website has the link applied), would result in the following:

    visit our website (see: "Author-it Home Page - http://www.author-it.com"), or

    visit our website (http://www.author-it.com)

    …depending on the Document settings chosen in the hypertext link object.

    -or-

  2. exclude the hyperlink from appearing in the Word output.

    For example, uncheck the include in on the General tab:

    General tab - Exclude from Word

    ...in which case the cross reference simply won't be created.

If choosing the second option, you can then use an AfterPublish macro to turn the URL into a clickable hyperlink in the Word document. The macro would need to turn the autoformat feature on (found in Word under Format > Autoformat > Options) then remove all the checkboxes apart from the Internet and network paths with hyperlinks.

Words Autoformat - Replace URLs with links

Note: This is the same method you would need to use in MS Word if you copied and pasted text containing a URL. A clickable link is not created until you have entered a space after the URL (provided you have the autoformat option enabled) or formatted the document as described above.

The following macro should do the trick, or at least serve as a good starting point:

 
Sub AfterPublish

' Turn the autoformat option on to replace internet 
' and network paths with hyperlinks 
    
    With Options
        .AutoFormatApplyHeadings = False
        .AutoFormatApplyLists = False
        .AutoFormatApplyBulletedLists = False
        .AutoFormatApplyOtherParas = False
        .AutoFormatReplaceQuotes = False
        .AutoFormatReplaceSymbols = False
        .AutoFormatReplaceOrdinals = False
        .AutoFormatReplaceFractions = False
        .AutoFormatReplacePlainTextEmphasis = False
        .AutoFormatReplaceHyperlinks = True
        .AutoFormatPreserveStyles = False
        .AutoFormatPlainTextWordMail = False
    End With
    Selection.Document.Kind = wdDocumentNotSpecified
    Selection.Range.AutoFormat
End Sub

Remember also that we've designed the Word output with the intention of it being a printed document, and not with the intention of it being viewed online.

Top of Page Email this Page Log Support Call Send Feedback Print