Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mail Merge document doesn't print in Windows XP

Status
Not open for further replies.

mfong75

Programmer
Apr 22, 2003
7
US
Hi,
I have the same code as in the FAQ to print labels from VFP 7.0. This works fine in a windows 2000 computer with Microsoft Word 2002 installed.

When I try it in a Windows XP with Microsoft Word 2003, it doesn't print the document at all and it doesn't give me an error either.

I've looked in many newsgroups with no luck. Thanks in advance,
Monica

#DEFINE wdMainDocumentOnly 1
#DEFINE wdMainAndDataSource 2
#DEFINE wdSendToPrinter 1
#DEFINE wdDoNotSaveChanges 0
#DEFINE wdWindowStateMinimize 2

oWord = CREATEOBJECT("Word.Application")
oWord.Visible = .f.
oWord.WindowState = wdWindowStateMinimize

** change the path and file name to suit
oWord.Documents.Open("&cgetfile")

** check to make sure the documnet is attached to a
** datasource and ready to merge.
If oWord.ActiveDocument.MailMerge.State = wdMainAndDataSource
oWord.ActiveDocument.MailMerge.Destination = wdSendToPrinter
oWord.ActiveDocument.MailMerge.DataSource.FirstRecord = 1
oWord.ActiveDocument.MailMerge.DataSource.LastRecord = -16
oWord.ActiveDocument.MailMerge.Execute
endif
oWord.Quit(wdDoNotSaveChanges) && close file no save
release oWord
 

Before you set the .Destination, execute again the
.OpenDataSource() command in order to re-establish the datasource again.

Office 2003 will clear the mail merge datasource if you programmatically open it.
This is one of the changes in Office 2003.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top