Results 1 to 11 of 11
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Identifying failed hyperlinks in Word document (Any)

    Hi

    I want a macro that checks that all hyperlinks in a Word document will work? I envisage it would work like this:
    1. <LI>Troll through all the fields
      <LI>Identify those that are hyperlinks
      <LI>Check whether the hyperlink's target exists
    I was going to have a go at it myself, but then thought that someone's sure to have done the work before. Is anyone aware of such a macro?

    PS: I searched WOPR for "failed AND hyperlink" before making this post, and was astonished to get only one hit. What's wrong with you people, don't you ever make any mistakes? <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Thanks
    Dale

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

    Re: Identifying failed hyperlinks in Word document (Any)

    What is the target of the hyperlinks? Files, URLs, e-mail addresses, a mixture?

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Identifying failed hyperlinks in Word document (Any)

    Hi Hans

    I was thinking of using it for Word documents that are going to be subjected to a process that creates an HTML version. I guess all the targets will be in one of the the following formats:<UL><LI>http address (eg, http://support.microsoft.com)
    <LI>www address (eg, www.microsoft.com) (but I think Word might convert that to an http anyway)
    <LI>filename (eg, abc.htm or abc.doc or abc.pdf or ...)
    <LI>filename at relative address (eg xyzabc.htm or ....downloadsabc.doc)[/list]In fact, it's more than just hyperlinks, isn't it. For example, images should be included (field type of INCLUDEPICTURE), and no doubt there are others.

    And I guess a full blown solution would also handle formats such as file://. And I suppose it sould also create a report containing warnings (eg, any "file://" address is suspect since it will fail when published on the net).

    However, if anything's out there, I'd be very interested. And if there isn't anything available, I'll have a go myself, but starting small.

    Thanks
    Dale

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

    Re: Identifying failed hyperlinks in Word document (Any)

    I, for one, don't have anything ready. If you create something yourself, please share it here. Thanks in advance.

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Identifying failed hyperlinks in Word document

    Dale, this is the mess of potage I came up with. It represents several chunks of code from my WbWrd and my utility library. It is not a final solution for you, but it shows you some of the contortions my mind went through about seven years ago. I know I test for different field types, and then performs actions depending on.

    1) If it is a hyperlink to a supposedly existing web page, I just leave it as is.
    2) A hyperlink to a Word doc is resolved to that doc, I open the doc and recurse.
    3) A hyperlink to a file is resolved to that file; I'm supposed to copy that file on my hard drive to an upload flder.
    4) Not sure what i do with mailto's
    5) I used to examine IncludeText fields, but they turned out to be a red herring.

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Identifying failed hyperlinks in Word document

    Hi Chris

    That's really kind and will get me off to a flying start. I'll post something back here when I (eventually) get somewhere with it.

    Thanks
    Dale

  7. #7
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Wellington, New Zealand
    Posts
    143
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Identifying failed hyperlinks in Word document

    Dale

    I asked a similar question a while back, but didn't find anything out there (<post#=66,767>post 66,767</post#>). I then spent weeks trying to create something with VBA, but gave up thinking that I just couldn't do it.

    What I did instead was start using a programme that checks the links in the HTML files once they've been created, and then fix any broken links in the Word documents before creating them again. The programme is HTML Link Validator, and it works well (though it can be tricky checking links that are activated via JavaScript).

    Good luck.

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Identifying failed hyperlinks in Word document (Any)

    Hi

    As promised, attached is an attempt at checking for failed hyperlinks (and INCLUDEPICTURE targets) in Word documents.

  9. #9
    Lounger
    Join Date
    Oct 2004
    Location
    Indianapolis, Indiana, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='dale.lacey' post='563989' date='17-Mar-2006 05:43']Hi

    As promised, attached is an attempt at checking for failed hyperlinks (and INCLUDEPICTURE targets) in Word documents.[/quote]
    I came here hoping to find VBA code that lets me verify the hyperlinks in a Word 2007 document. It sounds like the attachment that used to be here would get me going in the right direction, but the attachment appears to be missing. I guess it was dropped when Woody's Lounge got rejiggered and upgraded. Any of you administrative types know if and where I could find this code?

    Thanks

  10. #10
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='Andyman' post='783631' date='08-Jul-2009 15:54']if and where I could find this code? Thanks[/quote]
    I think this is the code I was referring to; I think Dale took it and developed something based on my ideas.
    This code comes from my "web word" compiler; It looks at each hyperlink in a document, and if the hyperlink points to an existing document, it processes THAT document.
    It is a document crawler, same idea as a web crawler.
    It processes each document only once, since the hyperlink structure may not be a true tree, that is, it may contain circular links.


    Code:
    Function ProcessHyperlinkTreeOfDocument(doc As Document)
    	Dim hlink As Hyperlink
    	For Each hlink In doc.Hyperlinks
    		Dim strHlinkName As String
    		strHlinkName = (hlink.Name)
    		Call AMLog(ThisDocument, "ProcessDocument with " & strHlinkName, os.blnMsgBox, True)
    		If blnDocumentLink(strHlinkName) Then
    			' Process this linked document
    			Dim strDocumentFullName As String
    			strDocumentFullName = strMakeFullName(doc, strHlinkName)
    			If UW.blnFileExists(strDocumentFullName) Then
    				If InStr(1, strOpened, strDocumentFullName) > 0 Then ' already processed
    					Call AMLog(ThisDocument, "ProcessDocument already processed " & strDocumentFullName, os.blnMsgBox, True)
    				Else
    					strOpened = strOpened & strDocumentFullName
    					Dim docLink As Document
    					Call AMLog(ThisDocument, "ProcessDocument opening " & strDocumentFullName, os.blnMsgBox, True)
    					Set docLink = Documents.Open(strDocumentFullName)
    					Call ProcessADocumentTree(docLink)
    					Call AMLog(ThisDocument, "ProcessDocument closing " & docLink.FullName, os.blnMsgBox, True)
    					docLink.Close (wdDoNotSaveChanges)
    					DoEvents ' required to avoid "losing" a hyperlink, believe it or not.
    				End If
    			Else
    				Call AMLog(ThisDocument, "ProcessDocument could not find" & strDocumentFullName, os.blnMsgBox, True)
    			End If
    		Else
    		End If
    	Next hlink
    End Function

  11. #11
    Lounger
    Join Date
    Oct 2004
    Location
    Indianapolis, Indiana, USA
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It looks the the ProcessADocumentTree code is code that actually manipulates the hyperlinks. Is this code built in VB, outside VBA and Word? I'm trying to verify hyperlinks (Web only) in Word 2007 while the document is open. It meatspace, this sounds like a much simpler process than what you've done. In cyberspace, though, it might be just as complicated.

Posting Permissions

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