by
dcooper@jade.co.nz >> Mon, 5 Mar 2007 22:19:09 GMT
Hi Didier,
From our experience, getting hyperlinks to work properly from Word document through to PDF conversion is a bit tricky!
Firstly, if you haven't already done so, have a read of the "JADE Online Help" section in Chapter 2 of the UserGuide.pdf manual (particularly the "Creating Context Links to Your Own Application Help File" section).
Next, here are some steps from the Work Instructions we use to produce our PDF manuals (we use Acrobat PDFMaker for Microsoft Office to convert from doc to PDF). The macros mentioned in the steps below are at the very bottom of this post.
1. Save your document. Kind of goes without saying, but then again...
2. Select the entire document except for the contents and the index, if the document has them. Right-click on white space to the side of the selection and then select the Update field command from the popup menu or press F9.
* Note - The Update field command is displayed only when you right-click on an area of the screen other than the selected text.
3. Save the document.
4. Copy your source file to a different directory by using Explorer, File Manager, or similar. You should copy all documents to the directory in which your PDF files are created and stored, possibly a subdirectory of the location of your source documents. (Saving files from Word to a different directory alters the paths of the hyperlinks incorrectly.)
* Caution - As you can no longer print documents from within Word or have them printed correctly when you have performed step 9, ensure that you first perform step 8.
* Caution - Ensure that you now turn off the display of field codes, by checking the Field codes check box on the Options dialog View sheet, before performing the following step.
5. Save your document.
6. When fields are displayed (by checking the Field codes check box on the Options dialog View sheet), run the PrepareHyperlinkedDocumentForConversionToPDF macro to add the named destination fields in the copy of the file created in the previous step and to change the hyperlink target file extensions from .doc to .pdf. This macro calls the AddNamedDestinationForBookmarkVeryFast and ChangeLinkExtensionDoc2Pdf macros. When all macros called by the PrepareHyperlinkedDocumentForConversionToPDF macro complete successfully, click the OK button on the message box that states Processing Completed: Document is now ready for conversion to PDF.
* Note - Before running Step 7, you must first change the FixDocumentNames macro to include your own document file names. Make sure that the uppercase and lowercase components of your file names are correct.
7. With fields still displayed (by checking the Field codes check box on the Options dialog View sheet), run the BookmarksAndHyperlinksToLowerCase macro (bookmarks must be all lowercase) and then the FixDocumentNames macro (the exact file names are included in the named destination fields so are also converted to lowercase, but they must be the correct case on Unix/Linux).
* Caution - Ensure that you now turn off the display of field codes, by checking the Field codes check box on the Options dialog View sheet, before performing the following step.
8. Select the entire document except for the contents and the index, if the document has them, and then press F9. (This updates the correct case in hyperlink document names.)
9. Save your document.
10. Convert the document (that is, the source document copy) to a PDF file, first selecting the Change Conversion Settings command from the Acrobat menu in Word and ensuring that the following check boxes on the Office sheet of the Acrobat PDFMaker for Microsoft Office conversion settings are not checked.
* Text Boxes --> Article Threads check box (a bug in PDFMaker causes an error if this is checked).
* Page Labels (e.g., iii, A-1) check box (the document margins cause PDFMaker to complain if this is checked).
* Embed Tags in PDF (Accessibility, Reflow) check box (the hyperlinks are converted to Open-File actions rather than to the required Go-To-View actions if this is checked).
* All check boxes other than these should be checked on the Office sheet.
Dean.
------------------------------
MACROS
Sub PrepareHyperlinkedDocumentForConversionToPDF()
' Macro created 21/11/06 by Jade Software Corporation Limited
AddNamedDestinationForBookmarkVeryFast
ChangeLinkExtensionDoc2Pdf
MsgBox ("Processing Completed: Document is now ready for conversion to PDF")
End Sub
Sub AddNamedDestinationForBookmarkVeryFast()
' Macro created 21/11/06 by Jade Software Corporation Limited
'
If ActiveDocument.Bookmarks.Count >= 1 Then
For Each abookmark In ActiveDocument.Bookmarks
Set aRange = abookmark.Range.Duplicate
aRange.Collapse Direction:=wdCollapseEnd
ActiveDocument.Fields.Add Range:=aRange, Type:=wdFieldEmpty, Text:= _
"PRINT ""[ /Dest /" + abookmark.Name + " /DEST pdfmark""", PreserveFormatting:=False
Next abookmark
End If
End Sub
Sub ChangeLinkExtensionDoc2Pdf()
'
' ChangeLinkExtensionDoc2Pdf Macro
' Macro created 19/11/2006 by Jade Software Corporation Limited
' Changed 10/12/2006 by Jade Software Corporation Limited
' Changed 10/02/07 by Jade Software Corporation Limited
'
If ActiveDocument.Hyperlinks.Count >= 1 Then
For Each alink In ActiveDocument.Hyperlinks
If IsObjectValid(alink) Then
pos = InStr(1, alink.Address, ".doc", vbTextCompare)
If pos > 1 Then
alink.Address = Mid(alink.Address, 1, pos - 1) + ".pdf" End If
End If
Next alink
End If
End Sub
Sub BookmarksAndHyperlinksToLowerCase()
Set bmks = ActiveDocument.Bookmarks
For Each abookmark In ActiveDocument.Bookmarks
If abookmark.Name <> LCase(abookmark.Name) Then
abookmark.Copy (LCase(abookmark.Name))
End If
Next abookmark
For Each aHyperlink In ActiveDocument.Hyperlinks
If aHyperlink.Address <> "" Then
aHyperlink.SubAddress = LCase(aHyperlink.SubAddress)
End If
Next aHyperlink
End Sub
Sub FixDocumentNames()
Selection.HomeKey Unit:=wdStory
ShowCodes = ActiveWindow.View.ShowFieldCodes
ActiveWindow.View.ShowFieldCodes = True
FindAndReplace "userguide.doc", "UserGuide.doc"
FindAndReplace "devref.doc", "DevRef.doc"
FindAndReplace "installconfig.doc", "InstallConfig.doc"
FindAndReplace "jade.doc", "JADE.doc"
FindAndReplace "jadeini.doc", "JADEini.doc"
FindAndReplace "admin.doc", "Admin.doc"
FindAndReplace "encyclosys1.doc", "EncycloSys1.doc"
FindAndReplace "encyclosys2.doc", "EncycloSys2.doc"
FindAndReplace "encyclowin.doc", "EncycloWin.doc"
FindAndReplace "jademsgs.doc", "JADEMsgs.doc"
FindAndReplace "objectmanager.doc", "ObjectManager.doc"
FindAndReplace "reportwriter.doc", "ReportWriter.doc"
FindAndReplace "releaseinfo.doc", "ReleaseInfo.doc"
FindAndReplace "jdbutil.doc", "JdbUtil.doc"
FindAndReplace "dumpload.doc", "DumpLoad.doc"
FindAndReplace "jademonitor.doc", "JadeMonitor.doc"
FindAndReplace "jadrap.doc", "JadRap.doc"
FindAndReplace "schemainspector.doc", "SchemaInspector.doc"
FindAndReplace "jadload.doc", "JadLoad.doc"
FindAndReplace "webmonitor.doc", "WebMonitor.doc"
ActiveWindow.View.ShowFieldCodes = ShowCodes
MsgBox ("Finished")
End Sub
Sub FindAndReplace(findString, replaceString)
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = findString
.Replacement.Text = replaceString
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub