Consulting

Results 1 to 4 of 4

Thread: Extracting hyperlinks

  1. #1
    VBAX Regular
    Joined
    Jan 2005
    Location
    Kansas, land of Dorothy and Toto
    Posts
    36

    Extracting hyperlinks

    Is there a way to extract all the hyperlinks in a Word document and list them in a table with the Text to Display in col 1 and the hyperlink in Col 2?
    Alas Babylon's Trivia Questions
    Three questions a day, Monday through Friday.
    To join, send e-mail to
    alasbabylon@gmail.com with SUBSCRIBE in the subject line.
    To leave, send e-mail to
    alasbabylon@gmail.com with UNSUBSCRIBE in the subject line
    http://groups.google.com/group/AlasBabylon?lnk=li

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Hi Alasbabylon.

    Finding hyperlinks with vba is easy: Simply look for hyperlink fields via the fields collection. Copying & inserting the hyperlink fields (or just their properties) into a table isn't especially difficult either.

    What have you tried so far?
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Regular
    Joined
    Jan 2005
    Location
    Kansas, land of Dorothy and Toto
    Posts
    36
    I haven't really tried anything yet - I don't know where to start. I thought I could do a search, but hyperlinks is not a search field - at least, noit in the Find dialog box. I'm don't have any VBA skills.
    Alas Babylon's Trivia Questions
    Three questions a day, Monday through Friday.
    To join, send e-mail to
    alasbabylon@gmail.com with SUBSCRIBE in the subject line.
    To leave, send e-mail to
    alasbabylon@gmail.com with UNSUBSCRIBE in the subject line
    http://groups.google.com/group/AlasBabylon?lnk=li

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Hi Alasbabylon.

    Here's some vba code to get you started. It's even simpler than working through the fields collection. Whn it finds a hyperlink it reports the hyperlink address and screen tip. I haven't included the code to write anything to a table for two reasons:
    1. You should spend a bit of time learning how to use vba; and
    2. You haven't given enough information about the table (eg does it already exist, if so, where is it, and can I rely on it already having enough rows).
    Sub FindHyperlinks()
    Dim hLnk As Hyperlink
    For Each hLnk In ActiveDocument.Hyperlinks
      MsgBox hLnk.Address & vbCrLf & hLnk.ScreenTip
    Next hLnk
    End Sub
    For your purposes, you need to replace the message box with the code tho output the same details to the table.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

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