This is strange. The code works fine on my machine. However, there is a problem on one of my user's machines. I don't know if it is VFP, Word, or our Print Server that is causing the problem.
The following code opens Word, Opens a merge Document (data is in Excel), performs a Merge, Saves the Document and Prints the Document. On the user's machine, sometimes pages are skipped. It might print pages 1-10, skip 11-16, print 17-25, etc. When I do this on my machine it always prints the entire document.
Even stranger, when the user opens the saved document and tries to print directly from Word, it still does not print the entire document. If I open it and print it it DOES print all.
Here is the code:
oWord = createobject('word.application')
set safety off
copy to x:\createpo.xls type xl5 for potype = aTypes[I, 1]
set safety on
* DWJ 06/29/1998 Load Letter merge document
oWord.documents.open(sgcPjDoc + '\' + aTypes[I, 2])
* DWJ 06/29/1998 Perform merge
oWord.activedocument.mailmerge.execute
set mark to '-'
cFileName = "x:\batch" + transform(date(), '@D') + '-' + alltrim(str(I))
set mark to
oWord.activedocument.SaveAs(cFileName)
oWord.activedocument.Printout()
oWord.activedocument.Close(.f.) && Close merge document
oWord.Documents(1).Activate()
oWord.activedocument.Close(.f.) && Close template document
* DWJ 06/29/1998 Kill the object reference
oWord = ""