Re: Mass Merging

Tech-Archive recommends: Fix windows errors by optimizing your registry



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" <Dagger.Depot.1prbd2@xxxxxxxxxxxxxxxxxxx> wrote in message
news:Dagger.Depot.1prbd2@xxxxxxxxxxxxxxxxxxxxxx
>
> 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


.



Relevant Pages

  • Re: Automatically naming documents with data in form fields?
    ... Dim myFile As String ... the proper folder for that template's documents. ... "Jay Freedman" wrote: ...
    (microsoft.public.word.docmanagement)
  • Re: Rules on the fly
    ... > incoming messages to a folder if they follow a thread that I'm not ... The References header (used to list the Message-ID of the original ... Without the References header to string together the messages, ...
    (microsoft.public.outlook)
  • Re: Rules on the fly
    ... > incoming messages to a folder if they follow a thread that I'm not ... The References header (used to list the Message-ID of the original ... Without the References header to string together the messages, ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: Rules on the fly
    ... > incoming messages to a folder if they follow a thread that I'm not ... The References header (used to list the Message-ID of the original ... Without the References header to string together the messages, ...
    (microsoft.public.outlook.general)
  • Re: Please Help with database upate. New to database
    ... Always put the files to be imported into the same folder. ... Public Sub ImportFilesInDirectory(ByVal strExtension As String) ... Dim strFinalPath As String ... "DestinationTable", myFile, False ...
    (comp.databases.ms-access)