Need a batch update of Doc Property Author  
Author Message
4nd3r5





PostPosted: Tue Aug 02 20:44:00 CDT 2005 Top

MS Word VBA >> Need a batch update of Doc Property Author

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.

Word230  
 
 
Greg





PostPosted: Tue Aug 02 20:44:00 CDT 2005 Top

MS Word VBA >> Need a batch update of Doc Property Author 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

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


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


 
 
phil





PostPosted: Thu Nov 17 10:20:15 CST 2005 Top

MS Word VBA >> Need a batch update of Doc Property Author Thanks. This helped with an issue I am trying to resolve for a user. - phil



> 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
>
> --
> Greg Maxey/Word MVP
> See:
> http://gregmaxey.mvps.org/word_tips.htm
> For some helpful tips using Word.
>

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