Results 1 to 12 of 12
  1. #1
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Convert Chapter Reference to Hyperlink Globally (Word 2003 / Windows XP SP2)

    Hello,
    I am looking for a Macro that I can point to a network folder and accomplish the following:

    1. Macro opens every word document at the folder level.
    2. Macro finds all plain text chapter references (e.g. See Chapter 200).
    3. Macro converts all plain text chapter references to hyperlinks (e.g. {HYPERLINK "Chapter 200.doc"} )
    4. The links are preserved when a PDF is made from all the chapters.

    Any assistance with this topic is very much appreciated.

    Regards,

    Jim

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

    Re: Convert Chapter Reference to Hyperlink Globally (Word 2003 / Windows X

    I have attached a variation of the macro I posted in your previous thread. Same warnings apply - always test on copies of the documents.
    Attached Files Attached Files

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Convert Chapter Reference to Hyperlink Globally (Word 2003 / Windows X

    The syntax errors are caused by breaking lines without including the _ line continuation character.

    Instead of
    <code>
    Set doc = Documents.Open(Filename:=StrPath &

    strFile, AddToRecentFiles:=False)
    </code>
    you should have
    <code>
    Set doc = Documents.Open(Filename:=StrPath & strFile, AddToRecentFiles:=False)
    </code>
    You have the same problem at the other places with red text.

    StuartR

  4. #4
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Convert Chapter Reference to Hyperlink Globally (Word 2003 / Windows X

    Too large picture shrunk by HansV

    Hello again Hans,

    I tested out your second Macro (variation of your first) and received some error messages. Attached is a screenshot of the error message.

    -J
    Attached Images Attached Images
    • File Type: gif x.gif (24.5 KB, 0 views)

  5. #5
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Convert Chapter Reference to Hyperlink Globally (Word 2003 / Windows X

    HUGE screenshot cropped by HansV. Please take a second to remove unnecessary white space from your picture attachments.

    Hello Stuart,

    Thanks for the posting. My Macro is running good now. When it is done, I can hyperlink to each of the documents (in Word that have references). However, when I go into Acrobat 7 Professional
    and "Create PDF From Multiple Files" (.doc), I get a PDF, but the links do not work anymore. Perhaps this is related to Adobe Acrobat (not Word). Anyway, for what it is worth, here is the error message
    I get.

    Perhaps I need to adjust the settings in Word or Acrobat. I am just not sure at this point.

    Any suggestions?

    Thanks again,

    -J
    Attached Images Attached Images
    • File Type: png x.PNG (3.7 KB, 0 views)

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

    Re: Convert Chapter Reference to Hyperlink Globally (Word 2003 / Windows X

    The link is to a Word document. Change the extension .doc in the macro to .pdf in the line

    Address:=strPath2 & Mid(strText, 5) & ".doc"

    and similarly in the other line that sets the address.

  7. #7
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Convert Chapter Reference to Hyperlink Globally (Word 2003 / Windows X

    Hello Hans,

    I changed the two lines of code (per your suggestion from .doc to .pdf) as shown here:

    Address:=strPath2 & Mid(strText, 5) & ".pdf", _
    TextToDisplay:="See Volume " & strVol & ", " & Mid(strText, 5)


    Address:=strPath2 & Mid(strText, 5, Len(strText) - 5) & ".pdf" & ")", _
    TextToDisplay:="(See Volume 4, " & Mid(strText, 5)



    There is one other line that had a .doc reference.

    Does that need to be changed too or not?

    That line reads as follows:

    strFile = Dir(strPath & "*.doc")


    So, with the two lines of code changed from .doc to .pdf, I re-ran the Macro, and the hyperlinks were inserted into the plain text.

    But, when I use Acrobat 7 Professional to "File>Create PDF From Multiple Files", the final PDF is still not working. Attached is the error message received in the PDF.

    Could not open the file

    '../../../../Word/WP 0101.doc'.

    Is this an issue with Adobe and how it converts the Hyperlinks in Word to Hyperlinks in a PDF or does something else need to be changed in the Macro?

    Do I need to create a style called Hyperlink?

    Thanks,

    -J
    Attached Images Attached Images

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

    Re: Convert Chapter Reference to Hyperlink Globally (Word 2003 / Windows X

    The line

    strFile = Dir(strPath & "*.doc")

    should *not* be changed. It is used to start looping through all Word documents in the specified folder.

    Are you sure that you converted the correct version of the Word documents to .pdf format? If the hyperlinks point to .pdf files in the Word documents, they should still point to .pdf files after conversion to .pdf.

    There ought to be no need to create a style named Hyperlink. Word should automatically apply it when the code creates the hyperlinks.

  9. #9
    3 Star Lounger
    Join Date
    Jan 2007
    Location
    Massachusetts, USA
    Posts
    272
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Convert Chapter Reference to Hyperlink Globally (Word 2003 / Windows X

    Hello Hans,

    I think we are talking about two different things here. I am using Adobe Acrobat 7 Professional to create ONE MASTER PDF from the folder full of word documents. I am NOT creating a PDF (1 for 1) for each word document.

    Jim

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

    Re: Convert Chapter Reference to Hyperlink Globally (Word 2003 / Windows X

    In that case, I don't know how to handle the hyperlinks. Perhaps someone who has experience with Adobe Acrobat and bookmarks can assist.

  11. #11
    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: Convert Chapter Reference to Hyperlink Globall

    Perhaps you need to combine all your Word documents and then create the PDF?

  12. #12
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Convert Chapter Reference to Hyperlink Globall

    If that is the case then you have opened a real can of worms. The hyperlinks between word documents are pointing at specific files (something.doc) and when you merge these into a single PDF the hyperlinks would naturally be still pointing at the specific Word files (something.doc). If you need these links to morph to point to a PDF file which doesn't yet exist then the matter becomes very complicated but not impossible.

    One way of doing this is to merge all the Word files into a megafile, get the links right, and then use the Acrobat Maker macro to create the PDF from one file. This is by far the easiest option.

    Another way of potentially doing it is to create a merged PDF as a placeholder, then set all the hyperlinks in the separate Word docs to point at that PDF, then recreate the merged PDF with the same name in the same location. You may need to post process the links in acrobat using javascript to remove the filepath from the links. The trick with this method is to recreate all the named anchors (target pages) that the hyperlinks can point at.

    Another way is to use the printer codes field in Word to create all the necessary anchors in Word before sending the files to PDF. This then gives the hyperlinks something to hit which is the biggest problem you face in what you are trying to do. Once you can be sure of what the targets are called (or will be called in the resulting PDF), the hyperlinks can be coded relatively easily.

    There may be a PDF software package which handles this type of job with a whole lot less time invested into a hand coded solution. Have a look at online forums like Planet PDF
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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