change mulptile fields across several doc's

T

tony

Is there a way to change fields across several different documents? We have
roughly 148 different document templates. Is there a way to set up fields in
these so that we can run a batch or something simmilar to change the headers
and footers on these files to match the project they will be applied to.

Probably a total of 2 -7 fields per document.
Project Name
Project ID
Contract #
and a couple more

Having to go through these all by hand to set up new projects takes to much
time...

thanks
 
D

Dave Lett

Hi Tony,

I've done something similar. Most the routine, by the way is from an article
on the Word MVPs site.

Dim sNewFileName As String
Dim sDocPath As String
Dim oDoc As Document
Dim MyFile As String
Dim Counter As Long

'insert the name of your directory
sDocPath = "C:\Test\"

'Create a dynamic array variable, and then declare its initial size
Dim DirectoryListArray() As String
ReDim DirectoryListArray(1000)

'Loop through all the files in the directory by using Dir$ function
MyFile = Dir$(sDocPath & "*.doc")
Do While MyFile <> ""
DirectoryListArray(Counter) = MyFile
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)

For Counter = 0 To UBound(DirectoryListArray)
Documents.Open FileName:=sDocPath & DirectoryListArray(Counter)
'''''Insert Routine or call routine that changes the fields

''' close document and save changes
ActiveDocument.Close SaveChanges:=wdSaveChanges
Next Counter


HTH,
Dave
 

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