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

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.

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default mailmerge with VBA using ACCESS 2000

You probably need

objWord.Quit after the close.

Peter Jamieson
"olgaz" wrote in message
news
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.


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
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
mail merge - Access 2000 and Word 2000 DawnMKA Mailmerge 1 March 26th 05 11:20 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 02:43 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"