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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Automation printing upsets Excel 1

Status
Not open for further replies.

MgtHargreaves

Programmer
May 12, 2006
33
GB
I have an interesting problem which one of our users brought to my attention - using automation to create and print a Word document. Having created and printed the Word document, if we then open an excel document (normally, not using vfp) and try to print the document, there is nothing in the printer name box. The code is as follows:
Code:
oWord=CREATEOBJECT("Word.Application")
oWord.Documents.Add("C:/xxxx/yyy.dot")
oWord.ActivePrinter = GETPRINTER()
oWord.printout(0)
oWord.ActiveDocument.Close(0)
I have established that the printer name box in Excel goes blank after the oWord.ActivePrinter = GETPRINTER() line.

Any-one got any ideas as to what is happening?
 
try this:
Code:
#DEFINE wdDialogFilePrintSetup 97
oWord = CreateObject("Word.Application")
oWord.Documents.Add("C:/xxxx/yyy.dot")
oWord.Visible = .t.
WITH oWord.Dialogs(wdDialogFilePrintSetup)
    .Printer=GETPRINTER()
    .DoNotSetAsSysDefault = .t.
    .execute()
ENDWITH
oWord.printout(0)
oWord.ActiveDocument.Close(0)
Not tested


Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top