Loading ...
Sorry, an error occurred while loading the content.

Re: [xenu-usergroup] Hyperlinks of a Word document

Expand Messages
  • Richard A. DeVenezia
    You can use Windows scripting to extract the hyperlinks found in Word documents, and write them to an html file so that Xenu can check them. Just be sure your
    Message 1 of 5 , Apr 1, 2005
    • 0 Attachment
      You can use Windows scripting to extract the hyperlinks found in Word
      documents, and write them to an html file so that Xenu can check them. Just
      be sure your exportFilename is linked to somewhere in the project.

      Richard A. DeVenezia


      extract-doc-links.vbs
      ------------------
      Option Explicit

      ' Doc link extracter
      ' Richard A. DeVenezia
      ' 1 Apr 2005

      Dim docFolder, exportFilename, xf
      Dim fso, oFolder, oFiles, oFile
      Dim oWordApp, oDoc, hLink

      Const ForWriting = 2

      ' Change these two to suit your needs
      docFolder = "C:\Temp"
      exportFilename = "C:\temp\hyperlinks-of-documents-in-temp.html"

      Set fso = CreateObject("Scripting.FileSystemObject")

      Set xf = fso.OpenTextFile (exportFilename, ForWriting, True)

      xf.Write "<HTML><HEAD></HEAD><BODY>" & vbCRLF
      xf.Write "<H1>Documents of " & docFolder & "</H1>" & vbCRLF

      Set oFolder = fso.GetFolder(docFolder)
      If oFolder Is Nothing Then
      WScript.Echo("Bad input directory")
      WScript.Quit
      End If
      Set oFiles = oFolder.Files

      Set oWordApp = CreateObject ("Word.Application")

      xf.Write "<UL>" & vbCRLF

      For Each oFile In oFiles
      If UCase(Right(oFile.Path, 4)) = ".DOC" Then

      xf.Write "<LI>Hyperlinks of " & oFile.Path & "</LI>" & vbCRLF
      xf.Write "<UL>" & vbCRLF

      Set oDoc = oWordApp.Documents.Open (oFile.Path, True, True) '
      Read-only

      For Each hLink In oDoc.Hyperlinks

      xf.Write "<LI><A HREF='" & hLink.Address & "'>" & hLink.Address &
      "</A></LI>" & vbCRLF

      Next

      xf.Write "</UL>" & vbCRLF

      oDoc.Close

      End If
      Next

      xf.Write "</UL>" & vbCRLF

      xf.Write "</BODY>"
      xf.Close

      oWordApp.Quit

      Set oWordApp = Nothing
      Set xf = Nothing
      ------------------
    • Catherine Mahe
      Thank you so much. I will try it. Cathy Mahe ... You can use Windows scripting to extract the hyperlinks found in Word documents, and write them to an html
      Message 2 of 5 , Apr 4, 2005
      • 0 Attachment
        Thank you so much. I will try it.

        Cathy Mahe

        >>> radevenz@... 04/01/05 02:33PM >>>


        You can use Windows scripting to extract the hyperlinks found in Word
        documents, and write them to an html file so that Xenu can check them.
        Just
        be sure your exportFilename is linked to somewhere in the project.

        Richard A. DeVenezia


        extract-doc-links.vbs
        ------------------
        Option Explicit

        ' Doc link extracter
        ' Richard A. DeVenezia
        ' 1 Apr 2005

        Dim docFolder, exportFilename, xf
        Dim fso, oFolder, oFiles, oFile
        Dim oWordApp, oDoc, hLink

        Const ForWriting = 2

        ' Change these two to suit your needs
        docFolder = "C:\Temp"
        exportFilename = "C:\temp\hyperlinks-of-documents-in-temp.html"

        Set fso = CreateObject("Scripting.FileSystemObject")

        Set xf = fso.OpenTextFile (exportFilename, ForWriting, True)

        xf.Write "<HTML><HEAD></HEAD><BODY>" & vbCRLF
        xf.Write "<H1>Documents of " & docFolder & "</H1>" & vbCRLF

        Set oFolder = fso.GetFolder(docFolder)
        If oFolder Is Nothing Then
        WScript.Echo("Bad input directory")
        WScript.Quit
        End If
        Set oFiles = oFolder.Files

        Set oWordApp = CreateObject ("Word.Application")

        xf.Write "<UL>" & vbCRLF

        For Each oFile In oFiles
        If UCase(Right(oFile.Path, 4)) = ".DOC" Then

        xf.Write "<LI>Hyperlinks of " & oFile.Path & "</LI>" & vbCRLF
        xf.Write "<UL>" & vbCRLF

        Set oDoc = oWordApp.Documents.Open (oFile.Path, True, True) '
        Read-only

        For Each hLink In oDoc.Hyperlinks

        xf.Write "<LI><A HREF='" & hLink.Address & "'>" & hLink.Address
        &
        "</A></LI>" & vbCRLF

        Next

        xf.Write "</UL>" & vbCRLF

        oDoc.Close

        End If
        Next

        xf.Write "</UL>" & vbCRLF

        xf.Write "</BODY>"
        xf.Close

        oWordApp.Quit

        Set oWordApp = Nothing
        Set xf = Nothing
        ------------------









        Yahoo! Groups Links
      • Richard A. DeVenezia
        ... If you ask real nice, maybe Tilman will roll the hyperlink retrieval process directly into Xenu for automatic processing. -Richard
        Message 3 of 5 , Apr 4, 2005
        • 0 Attachment
          Catherine Mahe wrote:
          > Thank you so much. I will try it.
          >
          > Cathy Mahe

          If you ask real nice, maybe Tilman will roll the hyperlink retrieval process
          directly into Xenu for automatic processing.

          -Richard
        • Tilman Hausherr
          ... Sorry, no, it s not that easy. What you showed seems to be Visual-Basic related. I don t know about something in Visual C++ that does the same. And even
          Message 4 of 5 , Apr 5, 2005
          • 0 Attachment
            On Mon, 4 Apr 2005 14:45:32 -0400, Richard A. DeVenezia wrote:

            >
            >
            >Catherine Mahe wrote:
            >> Thank you so much. I will try it.
            >>
            >> Cathy Mahe
            >
            >If you ask real nice, maybe Tilman will roll the hyperlink retrieval process
            >directly into Xenu for automatic processing.

            Sorry, no, it's not that easy. What you showed seems to be Visual-Basic
            related. I don't know about something in Visual C++ that does the same.
            And even then, I don't really have much time.

            Tilman
          • Tilman Hausherr
            New in the current beta: http://home.snafu.de/tilman/tmp/xenubeta.zip [Options] FailSimilarHosts=0 means that if one URL times out or has a broken connection,
            Message 5 of 5 , Apr 5, 2005
            • 0 Attachment
              New in the current beta:
              http://home.snafu.de/tilman/tmp/xenubeta.zip

              [Options]
              FailSimilarHosts=0

              means that if one URL times out or has a broken connection, the others
              don't fail as well. The default (and default / current) behaviour is
              "1", i.e. the others do fail.

              (This is for John)

              Tilman
            Your message has been successfully submitted and would be delivered to recipients shortly.