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 / June 2004

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Looby - 04 Jun 2004 14:32 GMT
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.
Cindy M  -WordMVP- - 06 Jun 2004 11:07 GMT
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
[quoted text clipped - 4 lines]
> 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)

<BG>Now, now. Stop knocking your head against the keyboard. Happens to
all of us!

> Here is my (very newbie) code so far:
> Sub envelope_postscript()
[quoted text clipped - 10 lines]
> 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 :-)
 
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.