Results 1 to 10 of 10
  1. #1
    2 Star Lounger
    Join Date
    May 2003
    Posts
    120
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hyperlinks (WordXP)

    I would like to put a hyperlink to a web page behind a button on a Word form. In Access there is a property of command buttons called "Hyperlink Address". Is there a similar way to do this in Word forms?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Hyperlinks (WordXP)

    Take a look at the FollowHyperlink method of the Document object.

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hyperlinks (WordXP)

    Hi Marie:
    Assuming that this is the same as Word 2000, do the following:
    1. Double-click a blank spot on a toolbar & choose customize.
    2. Drag any button to a toolbar or use an existing button.
    3. Right-click the button & choose Assign Hyperlink.
    4. Then pick a file, folder, or web page. The file will open in Word; the folder will open in Windows Explorer; the web page will open in IE.
    Cheers,

  4. #4
    2 Star Lounger
    Join Date
    May 2003
    Posts
    120
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hyperlinks (WordXP)

    Phil,

    Does Word only allow you to assign a hyperlink to a toolbar button? or, can you assign it to a command button on a form?

    Thanks.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hyperlinks (WordXP)

    See Jefferson's reply.

    Private Sub cmdWeb_Click()
    ActiveDocument.FollowHyperlink "http://www.wopr.com"
    End Sub

  6. #6
    Star Lounger
    Join Date
    Jan 2003
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hyperlinks (WordXP)

    Jefferson,

    I am having trouble following the hyperlinks. I have copied them from a Word document into an Access database. However, they don't work. The hyperlinks look like this:

    ..foldersubfolderdocument

    I think the problem is with the ..

    Is there a way to see the whole address?

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Hyperlinks (WordXP)

    The hyperlinks appear to have been "relative" to the folder the Word document was saved in. You probably have to add that path to the beginning of each of the links (except for the last level, since the .. indicates the parent folder of the one the Word document was in).

    How did you extract these peculiar links?

  8. #8
    Star Lounger
    Join Date
    Jan 2003
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hyperlinks (WordXP)

    I added these hyperlinks to my Word document from the Insert / Hyperlink menu. You are correct in saying that they were in a parent folder of the document. When I CTRL-click on the Hyperlink , the document opens.

    I now want to store the hyperlinks in an Access database. I have created a hyperlink field and set the value of it to the address of the hyperlink in the Word document. However, this field won't open the Word document. Is there any way in Word to determine the whole path for the Hyperlink? Alternatively, it would be great if when I insert the Hyperlinks into the Word document that they have the full address, so that I can paste them into the Access database.

    Thanks for your help.

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Hyperlinks (WordXP)

    Maybe some code like this, to run against the Word document. Little time for testing this. Does it seem to cover your various situations without errors?
    <pre>Option Explicit
    Sub ListLinks()
    'Manufacture full paths of hyperlinks; BETA MODE; NEEDS LOTS OF TESTING
    Dim link As Hyperlink, strPathSep As String
    For Each link In ActiveDocument.Hyperlinks
    'Set string to parse parts of paths
    If InStr(1, link.Address, "/") > 0 Then 'HTTP style link
    strPathSep = "/"
    Else
    strPathSep = Application.PathSeparator
    End If
    'Read link and try to complete it
    If InStr(1, link.Address, strPathSep) = 0 Then 'in current folder
    Debug.Print ActiveDocument.Path & strPathSep & link.Address
    Else
    Select Case Left(link.Address, 2)
    Case "" 'Complete UNC path
    Debug.Print link.Address
    Case ".." 'Relative link to parent folder; BAD RESULTS FOR HTTP LINKS
    Debug.Print Left(ActiveDocument.Path, InStrRev(ActiveDocument.Path, _
    Application.PathSeparator) - 1) & _
    Mid(link.Address, InStr(1, link.Address, strPathSep))
    Case Else 'Inspect more closely
    If Mid(link.Address, 2, 2) = ":" Then 'local or mapped drive probably
    Debug.Print link.Address
    ElseIf Left(link.Address, 1) = strPathSep Then 'In a subfolder
    Debug.Print Left(ActiveDocument.Path, InStrRev(ActiveDocument.Path, _
    Application.PathSeparator) - 1) & link.Address
    Else
    Debug.Print link.Address & " [unable to parse]"
    End If
    End Select
    End If
    Next link
    End Sub</pre>

    Upon reflection, it might be best, if HTML documents are linked, to work harder on those paths (e.g., file:// and flipping all the to /) but that would take even more testing. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  10. #10
    Star Lounger
    Join Date
    Jan 2003
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hyperlinks (WordXP)

    Thanks Jefferson. It is all working now!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •