Group:  Microsoft Word ยป microsoft.public.word.mailmerge.fields
Thread: mailmerge with VBA using ACCESS 2000

Geek News

mailmerge with VBA using ACCESS 2000
olgaz 6/25/2007 8:18:00 AM
Hello,

This is my routine code:

[Quoted Text]
> 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.

Re: mailmerge with VBA using ACCESS 2000
"Peter Jamieson" <pjj[ at ]KillmapSpjjnet.demon.co.uk> 6/25/2007 8:43:10 AM
You probably need

objWord.Quit after the close.

Peter Jamieson
"olgaz" <olgaz[ at ]discussions.microsoft.com> wrote in message
news:D765474A-BD1D-47E2-A4F4-7D02FD4FA574[ at ]microsoft.com...
[Quoted Text]
> 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.
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net