You are currently offline, waiting for your internet to reconnect

A hyperlink does not work in a Word document that is protected for forms

Support for Office 2003 has ended

Microsoft ended support for Office 2003 on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.

SYMPTOMS
You insert a hyperlink in a Microsoft Word document. Then, you protect the document for forms. When you click the hyperlink, it does not work.
MORE INFORMATION
If you want a hyperlink to work in a document that has been protected for forms, you must nest your HYPERLINK field in a MacroButton field. The MacroButton field must then call a macro that follows the hyperlink.

To enable a hyperlink to work in a document that is protected for forms, follow these steps:
  1. Open a Word document.
  2. Use the following Visual Basic for Applications (VBA) code to create a macro that is named FollowLink:
    Sub FollowLink()Selection.Hyperlinks(1).FollowEnd Sub
  3. Insert a hyperlink in the document when the form is unprotected.
  4. Select the hyperlink text, and then press ALT+F9 to display the HYPERLINK field code. You will see the HYPERLINK field code that is similar to the following example code:
    {HYPERLINK "http://www.mvps.org/word/"}    
  5. Select the HYPERLINK field code, and then press CTRL+F9. You will see the HYPERLINK field code text that is similar to the following example code:
    { {HYPERLINK "http://www.mvps.org/word/"} }
  6. Modify the HYPERLINK field code that is described in step 5 as follows:
    { MacroButton "FollowLink"{ HYPERLINK "http://www.mvps.org/word/" <AngularNoBind>}}</AngularNoBind>
    Note If you do not want the result to display a space after the URL, remove any spaces before and after the nested field.
  7. Select the MacroButton field code, press ALT+F9, and then press F9 to update the field and to display the hyperlink text.
  8. Double-click the hyperlink to open the Web site.

    Note By default, you must double-click the hyperlink to open the Web page. If you want the Web page to open when you single-click the hyperlink, you can use the following VBA code to create the AutoExec macro on the global template (Normal.dot):
    Sub AutoExecOptions.ButtonFieldClicks = 1End Sub               
    This macro will change the behavior of all MacroButton fields in all documents. Therefore, the Web pages to which all hyperlinks point will be opened when you single-click the hyperlinks.
If you want the MacroButton fields in documents that are based on certain templates to be followed when you single-click hyperlinks in some documents and when you double-click hyperlinks in other documents, you can use the DocumentChange event procedure. The DocumentChange event procedure contains the following code:
Private Sub oApp_DocumentChange()If ActiveDocument.AttachedTemplate.Name = _"MyTemplate.Dot" ThenOptions.ButtonFieldClicks = 1ElseOptions.ButtonFieldClicks = 2End IfEnd Sub
When you click a hyperlink, Word does not determine whether you are online before it tries to follow the hyperlink. If you are not connected to the Internet, Word does not prompt you to connect. Instead, Word continues to try unsuccessfully to follow the hyperlink before Word times out. You will experience this same issue when you nest your HYPERLINK field in a MacroButton field. This issue occurs because when you click an ordinary hyperlink in Word, you can continue to work while Word tries to follow the hyperlink. However, if you use a macro to follow a hyperlink, you cannot work until Word either opens the Web page to which the hyperlink points or times out. This issue occurs even if the following conditions are true:
  • The Web page that you want to open by using the hyperlink is in the Web browser cache.
  • You have made that Web page available offline.
You cannot use VBA code to verify whether a computer is connected to the Internet. However, you can use the following code to modify the FollowLink macro:
Sub FollowLink()Dim Result As LongResult = MsgBox("Are you definitely connected to the Internet?", _vbYesNo + vbQuestion)If Result = vbYes ThenSelection.Hyperlinks(1).FollowElseMsgBox "Please try again later", vbInformationEnd If
The macro will run when you click a hyperlink. Then, you will receive a message that prompts you whether you are connected to the Internet. If you click Yes, Word will try to open the Web page to which the hyperlink points. If you click No, you will receive the following message:
Please try again later.
WD2003 WD2002 WD2000
Properties

Article ID: 913761 - Last Review: 03/23/2006 02:26:39 - Revision: 2.2

  • Microsoft Office Word 2003
  • Microsoft Word 2002 Standard Edition
  • Microsoft Word 2000 Standard Edition
  • kbmacro kbtshoot KB913761
Feedback