Lisa,
You can use the following to create the document varialble
"productname" and set its value to Acme Widgets.
Sub BatchAddVariable
Dim MyFile As String
Dim PathToUse As String
Dim numWordsToUse As Long
Dim Counter As Long
Dim myDoc As Document
'Create a dynamic array variable, and then declare its initial size
Dim DirectoryListArray() As String
ReDim DirectoryListArray(1000) '1000 is arbitrary
'Specify folder containing files
PathToUse = "C:\Batch Folder\"
'Loop through all the files of *.doc type in the directory by using
Dir$ function
MyFile = Dir$(PathToUse & "*.doc")
'For each file found add to the array
Do While MyFile <> ""
DirectoryListArray(Counter) = MyFile
'Get the next file name
MyFile = Dir$
Counter = Counter + 1
Loop
'Reset the size of the array without losing its values by using Redim
Preserve
ReDim Preserve DirectoryListArray(Counter - 1)
Application.ScreenUpdating = False
For Counter = 0 To UBound(DirectoryListArray)
Set myDoc = Documents.Open(FileName:=PathToUse &
DirectoryListArray(Counter), _
Visible:=False)
With myDoc
.Variables("productname").Value = "Coswell Cogs"
.Save
.Close
End With
Next Counter
Application.ScreenUpdating = True
End Sub
Note this will not insert the { DocVariable "productname" } field in
your text. You would have to add more code to go to some point in the
document, insert the field code and update the fields.
Cost $1,000.000.00
See:
http://gregmaxey.mvps.org/word_tips.htm