#1   Report Post  
Dagger Depot Dagger Depot is offline
Junior Member
 
Posts: 1
Exclamation Mass Merging

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.
  #2   Report Post  
Doug Robbins
 
Posts: n/a
Default

If the letters were originally created using mailmerge, the simplest thing
would be to modify the mailmerge data main document by placing the necessary
information in the header and then re-execute the merge.

Otherwise, I would create a template with the necessary header information
in it and then use a modification of the code in the article the article
"Find & ReplaceAll on a batch of documents in the same folder" at:
http://word.mvps.org/FAQs/MacrosVBA/BatchFR.htm

to set a Range to the text in each letter, create a new document from the
template and then insert the Range into that document.

Post back if you need help with the VBA code.

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



  #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



  #4   Report Post  
Graham Mayor
 
Posts: n/a
Default

You could do this with a batch processing macro, provided all the documents
are in the same folder.

The following macro http://www.gmayor.com/installing_macro.htm will replace
the existing header with whatever header you first save as an autotext entry
called 'logo'.

If you wish to *add* the company header to an existing header, the code will
require modification - and if some of the documents have multiple sections
you will have to add code to process those sections, but the basic code will
work for simple documents. Try it on a few copies in a folder created for
the purpose.

If you want more help with this I will not be around again this weekend. Ask
your further questions in the VBA newsgroup.

Sub AddAHeader()
Dim myFile As String
Dim PathToUse As String
Dim myDoc As Document

' Get the folder containing the files
' Save the header to insert as an autotext entry
' called 'logo'
With Dialogs(wdDialogCopyFile)
If .Display 0 Then
PathToUse = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With

'Close any documents that may be open
If Documents.Count 0 Then
Documents.Close Savechanges:=wdPromptToSaveChanges
End If

If Left(PathToUse, 1) = Chr(34) Then
PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2)
End If

myFile = Dir$(PathToUse & "*.doc")

While myFile ""

'Open each file and make the replacement
Set myDoc = Documents.Open(PathToUse & myFile)
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Style = ActiveDocument.Styles("Normal")
NormalTemplate.AutoTextEntries("Logo").Insert Whe=Selection.Range, _
RichText:=True
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
myDoc.Close Savechanges:=wdSaveChanges
myFile = Dir$()
Wend

End Sub

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org





Dagger Depot wrote:
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.




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Merging hyper link from data source Jasy Mailmerge 3 June 1st 05 12:58 PM
How do keep blank lines when merging a document with the data and. Church secretary Mailmerge 3 March 31st 05 06:57 PM
Merging excel with Word $ and % format is lost when merging Mailmerge 1 March 31st 05 05:04 PM
Merging from Excel into word Wim Willemse Mailmerge 3 March 31st 05 12:17 PM
In merging from excel, fields are printing like "62.419999" when . rolando2609 Microsoft Word Help 2 March 12th 05 05:23 AM


All times are GMT +1. The time now is 09:59 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"