Here's a method that does not involve using the DSO File. It will ask you
to browse to the folder containing the documents for which you want to
update the HyperLinkBase, then it will ask you to browse to the folder that
is at the end of the HyperLinkBase, and then it will open each of the
documents in the folder and update the HyperLinkBase in each one and save
and close it.
Public Sub UpdateHyperlinkBase()
Dim myFile As String
Dim PathToUse As String
Dim HyperLinkBase As String
Dim myDoc As Document
'Close all open documents before beginning
Documents.Close SaveChanges:=wdPromptToSaveChanges
'Browse to the folder containing the documents
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.title = "Select the folder containing the files to be updated."
If .Show <> 0 Then
PathToUse = .SelectedItems(1)
Else
MsgBox "Dialog cancelled"
Exit Sub
End If
End With
'Get the new location of the HyperLinkBase
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
.title = "Select the new path for the Hyperlinks."
If .Show <> 0 Then
HyperLinkBase = .SelectedItems(1)
Else
MsgBox "Dialog cancelled"
Exit Sub
End If
End With
myFile = Dir$(PathToUse & "*.doc")
While myFile <> ""
'Open document
Set myDoc = Documents.Open(PathToUse & myFile)
'Change the HyperLinkBase and Save the Document
With myDoc
.BuiltInDocumentProperties(wdPropertyHyperlinkBase) = HyperLinkBase
.Close SaveChanges:=wdSaveChanges
End With
'Next file in folder
myFile = Dir$()
Wend
End Sub
If you don't know what to do with the code, see the article "What do I do
with macros sent to me by other newsgroup readers to help me out?" at:
http://www.word.mvps.org/FAQs/MacrosVBA/CreateAMacro.htm
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP