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 / July 2007

Tip: Looking for answers? Try searching our database.

mailmerge with VBA using ACCESS 2000  continue

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
olgaz - 01 Jul 2007 06:38 GMT
> Hello,
>
> This is my routine code:
>
>> Public Sub fmailmerge(myskey As String)
>> Dim objWord As Word.Document
>> Dim strMergeDoc, str, str2 As String
>> Dim mystudy As Variant
>>
>> Set objWord = GetObject(strMergeDoc, "Word.Document")
>> objWord.Application.Visible = False
>> objWord.MailMerge.OpenDataSource
>> "\\fserver-xp\fshare\Pidu\StudysDocuments\EpiPneumo\Stikers.mdb", , , ,
>> True,
>> , , , , , , "QUERY CasesToday", "Select * from CasesToday  where skey =
>> '" &
>> myskey & "'"
>> objWord.MailMerge.Destination = wdSendToNewDocument
>>
> The important thing is:
>>
>> objWord.MailMerge.Execute
>> objWord.Application.Options.PrintBackground = False
>> objWord.PageSetup.FirstPageTray = wdPrinterAutomaticSheetFeed
>> objWord.PageSetup.OtherPagesTray = wdPrinterAutomaticSheetFeed
>> objWord.Application.ActiveDocument.PrintOut
>
> I do not ask to save anything and I close Word:
>
>> objWord.Close (wdDoNotSaveChanges)
>> Set objWord = Nothing
>> End Sub
>
> The program works well and the document can be printed.  However, when
> login
> again, on the same computer, and opening Word, all those documents open
> automatically under the title recovered.
> How can I prevent this from happening each time?
>
> Thank you.

You probably need

objWord.Quit after the close.

Peter Jamieson
"olgaz" <olgaz@discussions.microsoft.com> wrote in message
news:D765474A-BD1D-47E2-A4F4-7D02FD4FA574@microsoft.com...

It's not working!!!!!!!!!!!!!!!!!!
Doug Robbins - Word MVP - 01 Jul 2007 08:05 GMT
Ater this line of code, insert

objWord.Application.ActiveDocument.PrintOut
objWord.Application.ActiveDocument.Close wdDoNotSaveChanges

Actually, I do not know why you have introduced the Application in that line
of code, so you probably only need:

objWord.ActiveDocument.PrintOut
objWord.ActiveDocument.Close wdDoNotSaveChanges

Signature

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

>> Hello,
>>
[quoted text clipped - 44 lines]
>
> It's not working!!!!!!!!!!!!!!!!!!
 
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.