W
Wilson Pye
Hi,
Problem is when performing a mail merge the template, header, and data docs
are opened behind the preview screen.
If they are not manually closed by the user, the header.doc remains open
and cannot be accessed again.
I would like to use the preview option before printing.
Is there a way to only have the mail merge doc open and make sure header
doc is closed?
I tried another approach which was simply to print the doc and quit word...
problem was the nasty message "If you quit you dont print"....
is there a way to issue the quit after printing is completed - no prompts?
I am automating Word from a VFP app. I am producing a doc for the purpose
of printing only. First I create a template. The template is a mail merge
document attached to a header source only. I run a query, then call a
routine to attach the header, populate and save template. I then create a
new .doc from the .dot, create the actual data source and perform the
merge.
If anyone is familiar with "Microsoft Office Automation with Visual FoxPro"
published by Hentzenwerke... I am using the their ideas and supplied code as
a guideline.
The end of the routine where I am doing the mail merge looks like this:
*****************
oWord.Visible = .T.
* Create a new document based on the template
cTemplatePath = oWord.Options.DefaultFilePath( wdUserTemplatesPath )
oDocument = oWord.Documents.Add( ADDBS(cTemplatePath) + "AuctionReceipt" )
SELECT auctionnam,itemnumber,itemdescri,;
charitynam,starttime,bid,tax,total,;
marketvalu,deductible,purflname,purco,;
purstreet1,purcity,purstate,purzip;
FROM tempaucitems;
INTO CURSOR tempaucitemscurs
DO CreateDataSource WITH oDocument, DBF("tempaucitems"), AddBs(SYS(2023)) +
"AucitemsReceiptData"
USE IN tempaucitemscurs
* Perform the mail merge
oDocument.MailMerge.Execute()
oMergedDocument = oWord.ActiveDocument
WITH oMergedDocument
IF .ActiveWindow.WindowState <> wdWindowStateMaximize
* Move it to make it visible - for some reason, it comes up
* way off screen
.ActiveWindow.Left = 0
.ActiveWindow.Top = 0
ENDIF
* Print document
* .PrintOut( , , wdPrintAllDocument)
* Preview it
.PrintPreview()
ENDWITH
ClOSE TABLES
RETURN
*****************
Any help would be much appreciated.
Wilson
Problem is when performing a mail merge the template, header, and data docs
are opened behind the preview screen.
If they are not manually closed by the user, the header.doc remains open
and cannot be accessed again.
I would like to use the preview option before printing.
Is there a way to only have the mail merge doc open and make sure header
doc is closed?
I tried another approach which was simply to print the doc and quit word...
problem was the nasty message "If you quit you dont print"....
is there a way to issue the quit after printing is completed - no prompts?
I am automating Word from a VFP app. I am producing a doc for the purpose
of printing only. First I create a template. The template is a mail merge
document attached to a header source only. I run a query, then call a
routine to attach the header, populate and save template. I then create a
new .doc from the .dot, create the actual data source and perform the
merge.
If anyone is familiar with "Microsoft Office Automation with Visual FoxPro"
published by Hentzenwerke... I am using the their ideas and supplied code as
a guideline.
The end of the routine where I am doing the mail merge looks like this:
*****************
oWord.Visible = .T.
* Create a new document based on the template
cTemplatePath = oWord.Options.DefaultFilePath( wdUserTemplatesPath )
oDocument = oWord.Documents.Add( ADDBS(cTemplatePath) + "AuctionReceipt" )
SELECT auctionnam,itemnumber,itemdescri,;
charitynam,starttime,bid,tax,total,;
marketvalu,deductible,purflname,purco,;
purstreet1,purcity,purstate,purzip;
FROM tempaucitems;
INTO CURSOR tempaucitemscurs
DO CreateDataSource WITH oDocument, DBF("tempaucitems"), AddBs(SYS(2023)) +
"AucitemsReceiptData"
USE IN tempaucitemscurs
* Perform the mail merge
oDocument.MailMerge.Execute()
oMergedDocument = oWord.ActiveDocument
WITH oMergedDocument
IF .ActiveWindow.WindowState <> wdWindowStateMaximize
* Move it to make it visible - for some reason, it comes up
* way off screen
.ActiveWindow.Left = 0
.ActiveWindow.Top = 0
ENDIF
* Print document
* .PrintOut( , , wdPrintAllDocument)
* Preview it
.PrintPreview()
ENDWITH
ClOSE TABLES
RETURN
*****************
Any help would be much appreciated.
Wilson