A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Graham Mayor -- individual merge letters



 
 
Thread Tools Display Modes
  #1  
Old December 8th, 2006, 03:27 PM posted to microsoft.public.word.mailmerge.fields
zoolaw444
external usenet poster
 
Posts: 16
Default 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  
Old December 8th, 2006, 04:20 PM posted to microsoft.public.word.mailmerge.fields
Graham Mayor
external usenet poster
 
Posts: 18,297
Default 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  
Old December 8th, 2006, 04:38 PM posted to microsoft.public.word.mailmerge.fields
zoolaw444
external usenet poster
 
Posts: 16
Default 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  
Old December 8th, 2006, 04:50 PM posted to microsoft.public.word.mailmerge.fields
Graham Mayor
external usenet poster
 
Posts: 18,297
Default 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  
Old December 8th, 2006, 05:13 PM posted to microsoft.public.word.mailmerge.fields
zoolaw444
external usenet poster
 
Posts: 16
Default 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  
Old December 8th, 2006, 05:38 PM posted to microsoft.public.word.mailmerge.fields
Graham Mayor
external usenet poster
 
Posts: 18,297
Default 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  
Old December 8th, 2006, 05:53 PM posted to microsoft.public.word.mailmerge.fields
zoolaw444
external usenet poster
 
Posts: 16
Default 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  
Old December 8th, 2006, 05:55 PM posted to microsoft.public.word.mailmerge.fields
zoolaw444
external usenet poster
 
Posts: 16
Default Graham Mayor -- individual merge letters

I almost forgot - there's a field in the footer as well that automatically
puts the filename there.
  #9  
Old December 8th, 2006, 06:07 PM posted to microsoft.public.word.mailmerge.fields
Graham Mayor
external usenet poster
 
Posts: 18,297
Default 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  
Old December 8th, 2006, 06:25 PM posted to microsoft.public.word.mailmerge.fields
zoolaw444
external usenet poster
 
Posts: 16
Default 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?
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:24 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.