Update Hyperlink Base Address across multiple Word 2007 documents

C

Chuck Whittemore

I need to update the Hyperlink Base Address (found in the Summary tab of the
document's Advanced Properties) in multiple documents in Word 2007. Doing it
manually takes much time, especially given the volume of documents needing to
be updated. Compounding the problem is that the file path has changed
multiple times, further inflates the time spent managing the hyperlink base
address.
 
D

Doug Robbins - Word MVP

See the article "Getting access to the Document Properties of a Word file"
at:

http://www.word.mvps.org/FAQs/MacrosVBA/DSOFile.htm

You can use

ActiveDocument.BuiltInDocumentProperties(wdPropertyHyperlinkBase) =
"C:\Temp"

to change the Hyperlink Base of each document

--
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
 
C

Chuck Whittemore

Thanks for the prompt response. Here's what I found/learned so far:

1. On Vista, I needed to run Command as Adminstrator in order to properly
register the DLL.

2. When I try to run the List File Properties add-in in Word, I get a Visual
Basic run-time error '5111'. This Microsoft Knowledgebase article addresses
the issue: http://support.microsoft.com/kb/920229.

3. Unfortunately, I'm not a VBA programmer (or any type of programmer), so
while I'm quite certain using
"ActiveDocument.BuiltInDocumentProperties(wdPropertyHyperlinkBase) =
"C:\Temp"" would do the trick, I don't have the first clue how to use it.

So, that leaves me with the same issue as I started with. I do appreciate
your response, and if there is any other way a novice like me can accomplish
this task I'd be grateful to be made aware of the solution.

Chuck
 
D

Doug Robbins - Word MVP

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top