View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.word.vba.beginners
Mike NG Mike NG is offline
external usenet poster
 
Posts: 87
Default Creating a new word doc and putting some VBA code behind it

On Sat, 19 Jul 2003 at 10:19:50, Doug Robbins - Word MVP (Doug Robbins -
Word MVP ) wrote:
See the article "Changing the selected (current) printer in Word without
changing the system default printer" at:

http://www.mvps.org/word/FAQs/Macros...CurPrinter.htm

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a consulting basis.

That was superb - worked a treat thanks

I'd still like to put an Application.Quit behind the _Close event of the
mail merge results document though. The only other solution would be to
put some code in the mail merge main document which loops round counting
document count with a DoEvents in between - which seems to be having
slight performance impacts on my system

This is the code in my mail merge main document

Option Explicit
Private Sub Document_Open()

Dim sDataSrc As String
Dim sThisDoc As String


sThisDoc = ThisDocument.Name
sThisDoc = Left(sThisDoc, Len(sThisDoc) - 4) & "Data.doc"
sDataSrc = ThisDocument.Path & "\" & sThisDoc
MailMerge.OpenDataSource sDataSrc
MailMerge.Execute

'Mail merge result document
ActiveDocument.Saved = True

'Mail merge main document
ThisDocument.Close False

Done:

End Sub
--
Mike