Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / February 2007

Tip: Looking for answers? Try searching our database.

File Names for MailMerge Documents

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kristen - 31 Jan 2007 23:10 GMT
How do you save a new document generated from an existing MailMerge
Template/Document as the same name as the original document/template rather
than MS Word creating a new document with the merge info and calling it
"Letter1."  For example, if my original document with the merge fields in it
is called Kristen when I select the merge function and the new document
opens, I want it to default to the name Kristen.doc when I use the
File-SaveAs command and then I will edit the file name before saving to be
Kristen013107(or something unique) before saving it so that it doesn't
overwrite the original Kristen.doc base merge template.

Likewise, is there a way after you save a file that is in a specified
directory after it has been merged, to have this file moved and/or copied to
another specified directory.  Thanks in advance for any help!
Graham Mayor - 01 Feb 2007 05:56 GMT
The document doesn't have a name until it is saved Letter1 is simply Word's
internal description.
If you want individual merge letters named from the data - see
http://www.gmayor.com/individual_merge_letters.htm

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

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

> How do you save a new document generated from an existing MailMerge
> Template/Document as the same name as the original document/template
[quoted text clipped - 11 lines]
> copied to another specified directory.  Thanks in advance for any
> help!
Kristen - 01 Feb 2007 15:55 GMT
Thanks for the link Graham.  The problem is that this macro also splits the
document into a new document for each record.   Basically what I want is to
have the new document named via a data line in the main document like this
does, but not the other part with the splitting.  Do you know where I can
find how to do this. It seems like it should be a fairly common request.  
Thanks in advance!

> The document doesn't have a name until it is saved Letter1 is simply Word's
> internal description.
[quoted text clipped - 16 lines]
> > copied to another specified directory.  Thanks in advance for any
> > help!
Graham Mayor - 01 Feb 2007 16:24 GMT
This sounds like you want to create 'versions' - see another macro on my web
site at http://www.gmayor.com/save_numbered_versions.htm which could be
adapted to your requirements

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

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

> Thanks for the link Graham.  The problem is that this macro also
> splits the document into a new document for each record.   Basically
[quoted text clipped - 31 lines]
>>> moved and/or copied to another specified directory.  Thanks in
>>> advance for any help!
Kristen - 01 Feb 2007 18:28 GMT
Hi Graham,

I actually don't want version numbers because the document needs to have the
result of a merged data field. Maybe it would be easier if I gave you an
example.  The merge document has a Case ID# in it called Case_ID.  The name
of the document is SoftwareNotice.doc.  When the new document is created
after the merge, when I go to Save it, I want it to look at the merge field
Case_ID and name the document SoftwareNotice1234.doc, assuming that 1234 was
the Case_ID. Does this make sense?  Thanks for all of your help and prompt
responses!

> This sounds like you want to create 'versions' - see another macro on my web
> site at http://www.gmayor.com/save_numbered_versions.htm which could be
[quoted text clipped - 35 lines]
> >>> moved and/or copied to another specified directory.  Thanks in
> >>> advance for any help!
Peter Jamieson - 01 Feb 2007 19:39 GMT
You can use a macro like the following to perform the merge, but only if
your mail merge main document does not have any <<Next record>> fields and
similar stuff such as <<Next record if>>

Peter Jamieson

Sub ProduceOneDocPerSourceRec()
'

' NB, needs bettor error management and doubtless other things a VBA expert
' will point out.

Dim intSourceRecord
Dim objMerge As Word.MailMerge
Dim strEman As String
Dim strOutputDocumentName As String
Dim TerminateMerge As Boolean

' Need to set up this object as the ActiveDocument changes when the
' merge is performed. Besides, it's clearer.

Set objMerge = ActiveDocument.MailMerge
With objMerge

' If no data source has been defined, do it here using OpenDataSource.
' But if it is already defined in the document, you should not need to
define it here.

'  .OpenDataSource _
'    Name:="whatever"

 intSourceRecord = 1
 TerminateMerge = False

 Do Until TerminateMerge
   .DataSource.ActiveRecord = intSourceRecord

   ' if we have gone past the end (and possibly, if there are no records)
   ' then the Activerecord will not be what we have just tried to set it to

   If .DataSource.ActiveRecord <> intSourceRecord Then
     TerminateMerge = True
   ' the record exists
   Else

    ' while we are looking at the correct activerecord,
     ' create the document path name
     ' e.g. - you will need to change this -
    strEman = StrReverse(objMerge.Name)
 StrReverse(Mid(strEman, InStr(1, strEman & ".", ".") + 1))

     strOutputDocumentName = _
       "c:\mydoc\" & _
       StrReverse(Mid(strEman, InStr(1, strEman & ".", ".") + 1)) & _
       .DataSource.Datafields("CaseID").Value & ".doc"

     .DataSource.FirstRecord = intSourceRecord
     .DataSource.LastRecord = intSourceRecord
     .Destination = wdSendToNewDocument
     .Execute

     ' The Activedocument is always the output document
     ' Add any parameters you need to these calls
     ActiveDocument.SaveAs strOutputDocumentName
     ActiveDocument.Close
     intSourceRecord = intSourceRecord + 1
   End If
 Loop
End With
End Sub

> Hi Graham,
>
[quoted text clipped - 51 lines]
>> >>> moved and/or copied to another specified directory.  Thanks in
>> >>> advance for any help!
Peter Jamieson - 02 Feb 2007 08:20 GMT
And you need to leave out this statement

>      ActiveDocument.Close

if you want to have the opportunity to change the nme before saving.

> You can use a macro like the following to perform the merge, but only if
> your mail merge main document does not have any <<Next record>> fields and
[quoted text clipped - 125 lines]
>>> >>> moved and/or copied to another specified directory.  Thanks in
>>> >>> advance for any help!
Graham Mayor - 02 Feb 2007 07:17 GMT
Hmmm. If it's a single record merge then the original split merge add-in
solution should work. This names the file from a field (CaseID) in the
document?

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

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

> Hi Graham,
>
[quoted text clipped - 55 lines]
>>>>> moved and/or copied to another specified directory.  Thanks in
>>>>> advance for any help!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.