Mail Merge Question - Saving Original File Name to Subsequent Merged Docs

J

John Looby

I believe I've asked this question before, and I apologize if you've
responded, but I'm stuck.

What I am trying to do:

I have a number of standard form letters that are bumped up against an
access database to populate the information. Once a mail merge has
been completed, users then do a "merge to new document" and save the
document.

Ideally, I would like the resulting .doc to be automatically saved
with a name that would identify it as emerging from the merge, with a
timedate stamp and the users name. For example, if I use Letter A.doc
for the merge, then merge to a new document, i would like it to be
saved as JLOOBLetterA060404.doc. I can get the date stamp and user
name to transfer over, I just can't get the file name of the source
merge doc.

Here is my (very newbie) code so far:
Sub envelope_postscript()
'

Dim docName As String
strdocname = Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4)
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.Name = strdocname
.Execute
End With

ActiveDocument.SaveAs FileName:="X:\LETTERS\ENVELOPES\" & docName &
Format(Now(), "yyyymmddhhmmss") & ".doc", FileFormat:= _
wdFormatDocument
ActivePrinter = "Apple LaserWriter 16/600 PS"
Application.PrintOut OutputFileName:="X:\LETTERS\ENVELOPES\" &
docName & Format(Now(), "yyyymmddhhmmss") & ".prn",
Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False

End Sub


This can't be as hard as I'm making it, and I appreciate any help.
 
C

Cindy M -WordMVP-

Hi John,
Ideally, I would like the resulting .doc to be automatically saved
with a name that would identify it as emerging from the merge, with a
timedate stamp and the users name. For example, if I use Letter A.doc
for the merge, then merge to a new document, i would like it to be
saved as JLOOBLetterA060404.doc. I can get the date stamp and user
name to transfer over, I just can't get the file name of the source
merge doc.
You must have been working at this for quite a while, and your brain has
turned to mush :)? Take a close look at how you're assigning docName
and strdocname.

1. You should declare strdocname, as well, or use only docName

2. I don't think you can assign ActiveDocument.MailMerge.Name (delete
that)

3. The FileSaveAs looks fine, if you decide to use strdocname (or remove
the str from in front of it, higher up)

Here is my (very newbie) code so far:
Sub envelope_postscript()
'

Dim docName As String
strdocname = Left(ActiveDocument.Name, Len(ActiveDocument.Name) - 4)
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.Name = strdocname
.Execute
End With

ActiveDocument.SaveAs FileName:="X:\LETTERS\ENVELOPES\" & docName &
Format(Now(), "yyyymmddhhmmss") & ".doc", FileFormat:= _

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top