Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
I copied the code and created Graham Mayor's macro to merge a form letter
merge document directly to individual Word documents and it worked. The only problem is that the new individual Word documents did not retain the formatting from the form letter merge. Can anyone help me fix this? If not, this defeats the whole purpose of using the mail merge because it would take me less time to type in the names and addresses of all the people I want to send the letter to than it would to go through each individual document and reformat it (i.e., paragraph alignment, spacing, etc.) Cortney |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
I have spoken with Doug (who wrote the macro) about this. His response:
Create a template that has the required settings and then in the Private Sub app_MailMergeAfterMerge(ByVal Doc As Document, ByVal DocResult As Document) routine, replace the line of code: Set NewDoc = Documents.Add(Visible:=False) with Set NewDoc = Documents.Add(Template:="c:\documents and settings\[username]\application data\microsoft\templates\[TemplateName].dot", Visible:=False) Where the [username] is whatever is appropriate for the path to your templates folder and [TemplateName] is the name of the template that you created with the required settings. I think that you should then get the desired result. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org zoolaw444 wrote: I copied the code and created Graham Mayor's macro to merge a form letter merge document directly to individual Word documents and it worked. The only problem is that the new individual Word documents did not retain the formatting from the form letter merge. Can anyone help me fix this? If not, this defeats the whole purpose of using the mail merge because it would take me less time to type in the names and addresses of all the people I want to send the letter to than it would to go through each individual document and reformat it (i.e., paragraph alignment, spacing, etc.) Cortney |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
Grahan, I appreciate your prompt response but I'm confused.
First of all, to make sure we're on the same page, this is the macro I'm using: Sub SplitMerge() ' splitter Macro ' Macro created 16-08-98 by Doug Robbins to save each letter created by a ' mailmerge as a separate file. ' with modifications by Graham Mayor 16-06-03 & 08-10-04 Dim Title As String Dim Default As String Dim MyText As String Dim MyName As Variant Dim MyPath As String Selection.EndKey Unit:=wdStory Letters = Selection.Information(wdActiveEndSectionNumber) Selection.HomeKey Unit:=wdStory Counter = 1 Default = "Merged" MyText = "Enter a filename. Long filenames may be used." Title = "File Name" MyName = InputBox(MyText, Title, Default) If MyName = "" Then End End If Default = "D:\My Documents\Test\" Title = "Path" MyText = "Enter path" MyPath = InputBox(MyText, Title, Default) If MyPath = "" Then End End If While Counter Letters Application.ScreenUpdating = False Docname = MyPath & LTrim$(Str$(Counter)) & " " & MyName & ".doc" ActiveDocument.Sections.First.Range.Cut Documents.Add With Selection .Paste .EndKey Unit:=wdStory .MoveLeft Unit:=wdCharacter, Count:=1 .Delete Unit:=wdCharacter, Count:=1 End With ActiveDocument.SaveAs FileName:=Docname, FileFormat:=wdFormatDocument ActiveWindow.Close Counter = Counter + 1 Application.ScreenUpdating = True Wend End Sub Is it here in the macro code itself that I need to replace the line of code you indicated? If so, I don't see the "Private Sub app_MailMergerAfterMerge(ByVal Doc As Document, ByVal DocResult As Document)" part that you said to replace. If not, then please tell me where to find this in order to replace it because... I'm a total beginner here. Your help is GREATLY appreciated! |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
You are right - we are not on the same page. I asumed that yuou meant Doug's
add-in about which this issue has come up before. The principle is still the same however especially as this macro was developed from another of Doug's . Find the line Documents.Add and change it to Documents.Add(Template:="c:\path\[TemplateName].dot") substituting the path and template name as indicated in Doug's suggestion. That hopefully will do the trick. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org zoolaw444 wrote: Grahan, I appreciate your prompt response but I'm confused. First of all, to make sure we're on the same page, this is the macro I'm using: Sub SplitMerge() ' splitter Macro ' Macro created 16-08-98 by Doug Robbins to save each letter created by a ' mailmerge as a separate file. ' with modifications by Graham Mayor 16-06-03 & 08-10-04 Dim Title As String Dim Default As String Dim MyText As String Dim MyName As Variant Dim MyPath As String Selection.EndKey Unit:=wdStory Letters = Selection.Information(wdActiveEndSectionNumber) Selection.HomeKey Unit:=wdStory Counter = 1 Default = "Merged" MyText = "Enter a filename. Long filenames may be used." Title = "File Name" MyName = InputBox(MyText, Title, Default) If MyName = "" Then End End If Default = "D:\My Documents\Test\" Title = "Path" MyText = "Enter path" MyPath = InputBox(MyText, Title, Default) If MyPath = "" Then End End If While Counter Letters Application.ScreenUpdating = False Docname = MyPath & LTrim$(Str$(Counter)) & " " & MyName & ".doc" ActiveDocument.Sections.First.Range.Cut Documents.Add With Selection .Paste .EndKey Unit:=wdStory .MoveLeft Unit:=wdCharacter, Count:=1 .Delete Unit:=wdCharacter, Count:=1 End With ActiveDocument.SaveAs FileName:=Docname, FileFormat:=wdFormatDocument ActiveWindow.Close Counter = Counter + 1 Application.ScreenUpdating = True Wend End Sub Is it here in the macro code itself that I need to replace the line of code you indicated? If so, I don't see the "Private Sub app_MailMergerAfterMerge(ByVal Doc As Document, ByVal DocResult As Document)" part that you said to replace. If not, then please tell me where to find this in order to replace it because... I'm a total beginner here. Your help is GREATLY appreciated! |
#5
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
If I understood your directions correctly, I didn't do it right.
I went in to edit the SplitMerge Macro. Where it said Documents.Add in the code, I replaced it with Documents.Add(Template:="c:\Documents and Settings\Cortney\Application Data\Microsoft\Templates\Letter.dot"). The code was in red and I got a syntax error message when I tried to run the macro. Any suggestions? |
#6
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
Plan B
Documents.Add("c:\Documents and Settings\Cortney\Application Data\Microsoft\Templates\Letter.dot"). You will need a template without content - containing only the paragraph styles used in the original template. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org zoolaw444 wrote: If I understood your directions correctly, I didn't do it right. I went in to edit the SplitMerge Macro. Where it said Documents.Add in the code, I replaced it with Documents.Add(Template:="c:\Documents and Settings\Cortney\Application Data\Microsoft\Templates\Letter.dot"). The code was in red and I got a syntax error message when I tried to run the macro. Any suggestions? |
#7
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
Hmm... let's attack this from a different angle.
I'm printing this letter (which is two pages) on company letterhead. Normally, the letter template we use had a header on the first page only of about 3.25" to accommodate the company logo at the top. The second page also has a header, but much smaller because it only contains the following left alligned text: "Page # & the date here" There's a page break separating the first and second page. I'm not sure what you mean by paragraph styles. Does that help give you an idea of what I need? |
#8
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
I almost forgot - there's a field in the footer as well that automatically
puts the filename there. |
#9
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
Ok. If you use the letter head template you will probably duplicate any
standing text from the header/footer is you use it to create the separate documents. So make a copy of the template (or even a document from it). it doesn't matter where you store it as long as you have the correct path and filename. Delete the text from the header/footer and save it. It will already have the styles and with luck the documents will be formatted to match that template. Let's hope this works as I will not be around until tomorrow to pick the bones from it. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org zoolaw444 wrote: Hmm... let's attack this from a different angle. I'm printing this letter (which is two pages) on company letterhead. Normally, the letter template we use had a header on the first page only of about 3.25" to accommodate the company logo at the top. The second page also has a header, but much smaller because it only contains the following left alligned text: "Page # & the date here" There's a page break separating the first and second page. I'm not sure what you mean by paragraph styles. Does that help give you an idea of what I need? |
#10
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
Graham, hopefully I catch you before you take off...
Just to make sure I'm running the macro correctly... I'm running it once/after I've created the merged document that contains all the letters. I'm in the merged document and then I run the macro. Is that right? |
#11
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
I'm so excited!!!!! I got the mail merge into individual documents to work
AND it retained my different first page and second page header and footer. The only problem I have now is that it also created two extra blank pages (by a section break (next page) and a page break) at the end of every individual document. I took the page break separating the first and second page out of the original letter and the template I used, so I don't think that's the problem. I did noticed that in the single merged document (from which I run the macro to separate into individual documents) that there's a section break (next page) in-between each letter and then a section break (continuous) and a return after the very last letter. I thought that might be part of the problem but when I delete this last break, it screws up the pagination on the last letter. If I could fix this one last glitch, I should be good to go. Whew, you have no idea how long I've been struggling with this. |
#12
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
Insert the following line of code before ActiveDocument.SaveAs
FileName:=Docname, FileFormat:=wdFormatDocument AcitveDocument.Sections(ActiveDocuemnt.Sections.Co unt).PageSetup.SectionStart = wdSectionContinuous -- 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 "zoolaw444" wrote in message ... I'm so excited!!!!! I got the mail merge into individual documents to work AND it retained my different first page and second page header and footer. The only problem I have now is that it also created two extra blank pages (by a section break (next page) and a page break) at the end of every individual document. I took the page break separating the first and second page out of the original letter and the template I used, so I don't think that's the problem. I did noticed that in the single merged document (from which I run the macro to separate into individual documents) that there's a section break (next page) in-between each letter and then a section break (continuous) and a return after the very last letter. I thought that might be part of the problem but when I delete this last break, it screws up the pagination on the last letter. If I could fix this one last glitch, I should be good to go. Whew, you have no idea how long I've been struggling with this. |
#13
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
Doug's suggestion didn't work. Any ideas?
|
#14
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
Not really. It is almost certainly related to the template you are now using
with the macro. It really only needs to contain the margins and the styles used in the letter document. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org zoolaw444 wrote: Doug's suggestion didn't work. Any ideas? |
#15
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
I've modified the template as many different ways as I can think of but it
doesn't make any difference. I will just manually delete the extra page break and section break at the end of each document. Thank you very much for your assistance. |
#16
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
I assume that you corrected the spelling mistakes in the command that I
suggested. -- 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 "zoolaw444" wrote in message ... Doug's suggestion didn't work. Any ideas? |
#17
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
Yes, I corrected your typing errors. When I run the macro with the additional
code, there's no change. It looks like what it's doing is creating a new document for each individual letter that contains the section breaks and page breaks for two complete letters within each individual document. When I open each document, there's the letter itself with the large header on the first page to accommodate our letterhead logo and a smaller header on the second page, then a section break. In the new section after the section break, it repeats itself - again the large header on the first page, then a page break, and a second page with the smaller header only both these extra pages ges are blank. "Doug Robbins - Word MVP" wrote: I assume that you corrected the spelling mistakes in the command that I suggested. -- 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 "zoolaw444" wrote in message ... Doug's suggestion didn't work. Any ideas? |
#18
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
The problem is your section break in the original letter template. Section
breaks are rarely (if ever) needed in a letter template - see http://sbarnhill.mvps.org/WordFAQs/Letterhead.htm. It might be worth correcting the template and the original merge letter to avoid the section breaks and then the problem shouldn't arise in the first place. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org zoolaw444 wrote: Yes, I corrected your typing errors. When I run the macro with the additional code, there's no change. It looks like what it's doing is creating a new document for each individual letter that contains the section breaks and page breaks for two complete letters within each individual document. When I open each document, there's the letter itself with the large header on the first page to accommodate our letterhead logo and a smaller header on the second page, then a section break. In the new section after the section break, it repeats itself - again the large header on the first page, then a page break, and a second page with the smaller header only both these extra pages ges are blank. "Doug Robbins - Word MVP" wrote: I assume that you corrected the spelling mistakes in the command that I suggested. -- 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 "zoolaw444" wrote in message ... Doug's suggestion didn't work. Any ideas? |
#19
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
What do you mean by "original letter template"? The template I created (mail
merge.dot) which I then used in the SplitMerge macro does not have any page breaks or sections breaks, nor does the letter I start with. This is what I'm doing: Open the letter I'm using in Word Tools - Letters and Mailings - Mail Merge Use the current document Select your contacts In the "write your letter" part I added the address fields Complete the merge Edit individual letters (Here, Word creates the single document that contains all of my letters, each letter separated by a section break. This is the first time section breaks appear and they are automatically generated by the process Word goes through in doing the mail merge. It's in this document that I run the macro.) Does this make sense? |
#20
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
Something that you should check - with your mail merge main document open,
if you go into File|Page Setup, is the document set up for double-sided paper, mirror margins, or anything else "unusual" ? In particular is Pages|Multiple pages on the "Margins" tab set to anything other than "Normal" ? Peter Jamieson "zoolaw444" wrote in message ... Yes, I corrected your typing errors. When I run the macro with the additional code, there's no change. It looks like what it's doing is creating a new document for each individual letter that contains the section breaks and page breaks for two complete letters within each individual document. When I open each document, there's the letter itself with the large header on the first page to accommodate our letterhead logo and a smaller header on the second page, then a section break. In the new section after the section break, it repeats itself - again the large header on the first page, then a page break, and a second page with the smaller header only both these extra pages ges are blank. "Doug Robbins - Word MVP" wrote: I assume that you corrected the spelling mistakes in the command that I suggested. -- 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 "zoolaw444" wrote in message ... Doug's suggestion didn't work. Any ideas? |
#21
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
Thanks for the suggestion. I checked that and that doesn't seem to be the
issue. I wish it were that simple! |
#22
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
The only way to help you with this will be for you to send me the mailmerge
main document so that I can have a look at it. -- 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 "zoolaw444" wrote in message ... Thanks for the suggestion. I checked that and that doesn't seem to be the issue. I wish it were that simple! |
#23
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
I was just about to make the same suggestion as Doug :-)
Peter Jamieson "zoolaw444" wrote in message ... Thanks for the suggestion. I checked that and that doesn't seem to be the issue. I wish it were that simple! |
#24
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
Is that an option? If so, please provide me with contact info.
|
#25
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
|
#26
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
Thanks! I emailed you the document at the address you provided.
|
#27
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
I have not received it yet, could you check that you correctly de-spammed
the email address and send it again. -- 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 "zoolaw444" wrote in message ... Thanks! I emailed you the document at the address you provided. |
#28
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
I'm certain I did, but I resent it just in case.
|
#29
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
For others following, this issue was resolved by having the user use the
following code. I have not analysed where it differs from what she was using from Graham's website ' splitter Macro ' Macro created by Doug Robbins to save each letter created by a mailmerge ' as a separate file, retaining the header and footer information. Dim i As Long, Source As Document, Target As Document, Letter As Range Set Source = ActiveDocument For i = 1 To Source.Sections.Count Set Letter = Source.Sections(i).Range Set Target = Documents.Add Target.Range.FormattedText = Letter.FormattedText Target.Sections(Target.Sections.Count).PageSetup.S ectionStart = wdSectionContinuous Target.SaveAs FileName:="Letter" & i Target.Close Next i -- 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 "zoolaw444" wrote in message ... I'm certain I did, but I resent it just in case. |
#30
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Graham Mayor -- individual merge letters
It is actually nothing like the original code ... but it could be soon
-- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Doug Robbins - Word MVP wrote: For others following, this issue was resolved by having the user use the following code. I have not analysed where it differs from what she was using from Graham's website ' splitter Macro ' Macro created by Doug Robbins to save each letter created by a mailmerge ' as a separate file, retaining the header and footer information. Dim i As Long, Source As Document, Target As Document, Letter As Range Set Source = ActiveDocument For i = 1 To Source.Sections.Count Set Letter = Source.Sections(i).Range Set Target = Documents.Add Target.Range.FormattedText = Letter.FormattedText Target.Sections(Target.Sections.Count).PageSetup.S ectionStart = wdSectionContinuous Target.SaveAs FileName:="Letter" & i Target.Close Next i "zoolaw444" wrote in message ... I'm certain I did, but I resent it just in case. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Save mail merge as individual letters. | Mailmerge | |||
Mail merge in form letters from Access | Mailmerge | |||
After merge I need to see the letters under the prompt box to edit | Mailmerge | |||
only one page of mail merge document is printing | Microsoft Word Help | |||
Query a mail merge for multiple letters at once? | Mailmerge |