Need a batch update of Doc Property Author

C

CJ

Anyone know where I can get a macro or mechanism whcih will load a value into
the document property: Author? I have 650 docs in a folder which all have to
be updated. Loading other property values would be useful as well. Thanks
for any assistance.
 
G

Greg Maxey

CJ,


This is rather generic, but might get you started:

Public Sub BatchReplaceDocProperties()

Dim myFile As String
Dim PathToUse As String
Dim myDoc As Document
Dim Expr1 As String

'close any open documents

If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If

' Get the folder containing the files
MsgBox "Click OK. When the Copy dialog box appears drill down to the
applicable folder and click on Open.", , "User Instructions"
With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
PathToUse = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With

' PathToUse = "D:\My Documents\Word Documents\Word Tips\Macros\"
If Left(PathToUse, 1) = Chr(34) Then
PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2)
End If

Expr1 = InputBox("Enter the Document Subject:", "Subject")
'Set the directory and type of file to batch process
myFile = Dir$(PathToUse & "*.doc")
While myFile <> ""
'Open document
Set myDoc = Documents.Open(PathToUse & myFile)
'Ensure Word will sense change and resave
myDoc.Saved = False
'Set DocProperty
With myDoc
.BuiltInDocumentProperties("Title").Value = Expr1
End With
myDoc.Close SaveChanges:=wdSaveChanges
'Process next file in folder
myFile = Dir$()
Wend
End Sub
 

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