Thread: Mass Merging
View Single Post
  #3   Report Post  
Doug Robbins
 
Posts: n/a
Default

Here is the code that you will need. BEFORE RUNNING THE CODE, I would
suggest that you make a copy of all of the documents in another folder just
in case something goes wrong.

Dim myFile As String, PathToUse As String, SourceName As String
Dim Source As Document, Target As Document
'Modify the path in the following statement so that it points
'to the folder where the documents are located.
PathToUse = "C:\Test\"
'Close all open documents before beginning
Documents.Close SaveChanges:=wdPromptToSaveChanges
myFile = Dir$(PathToUse & "*.doc")
While myFile ""
'Create a new document containing the header information.
Set Target = Documents.Add("template with the header in it.dot")
'Open document containing the text
Set Source = Documents.Open(PathToUse & myFile)
'Get the name of the document
SourceName = Source.FullName
'Set the text in the new document equal to the text in the source
document
Target.Range.FormattedText = Source.Range.FormattedText
'Close the source document
Source.Close wdDoNotSaveChanges
'Save the new document with the name of the source document
Target.SaveAs SourceName
'Next file in folder
myFile = Dir$()
Wend


--
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
"Dagger Depot" wrote in message
news

Is it possible to merge a header into thousands of word documents using
some kind of merging program?

My company had me working on creating thousands of documents over the
last couple of weeks, and now decided they want a company header put
into the documents. These have to be done this weekend; no "if's,
and's or but's about it".

Any help will be extremely appreciated.


--
Dagger Depot