Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
olgaz olgaz is offline
external usenet poster
 
Posts: 2
Default mailmerge with VBA using ACCESS 2000 continue

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.m db", , , ,
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" wrote in message
news
It's not working!!!!!!!!!!!!!!!!!!
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default mailmerge with VBA using ACCESS 2000 continue

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

--
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

"olgaz" wrote in message
...
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.m db", , , ,
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" wrote in message
news
It's not working!!!!!!!!!!!!!!!!!!



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mailmerge with VBA using ACCESS 2000 olgaz Mailmerge 1 June 25th 07 09:43 AM
Word 2000 mail merge documents won't save Access 2000 data source Andy C Mailmerge 1 May 17th 06 08:39 AM
Using Access 97 for Word 2000 Mailmerge Rich F Mailmerge 2 December 26th 05 03:54 PM
Mailmerge Word 2000 Access 2000 Gale Coleman - LSND Mailmerge 1 November 11th 05 02:22 AM
MailMerge Word 2003 to Access 2000 query blank data BCool Mailmerge 1 January 15th 05 12:31 AM


All times are GMT +1. The time now is 12:37 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"