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

error when setting activprinter in Word

Status
Not open for further replies.

OhioBill

Programmer
Nov 10, 2003
66
US
I’m using VFP7 with Windows 2000 with Terminal Server 2003. The application is a Word document retrieval system, and has a command button which allows the user to send a selected document to a user specified printer. The code involved is:

lc_printer = Getprinter()

oWord = Createobject("Word.Application")
oWord.Documents.Open(<filename>, .F., .T., .F., <password>)
oWord.Visible = .F.

oWord.activeprinter = Alltrim(lc_printer)

oWord.Options.PrintBackground = .F.
oWord.Documents(SubA).PrintOut()

This application runs fine on my desktop, but when I run it under terminal server Word throws the error “OLE IDispatch exception code 0 from Microsoft Word: 'ActivePrinter' is not a by reference property...” when I assign a value to the activeprinter property.

I’ve tried stripping any nonprintable characters out of the printer name, to no avail. I’ve also tried printing from word and selecting the same printer name that causes the error, and have no problem. What am I doing wrong here?
 

Perhaps the Alltrim is causing the problem? Both of these work on VFP8.0, Word 2003 and XP (SP2)

Code:
o = CREATEOBJECT('word.application')
lpr = GETPRINTER()
o.ActivePrinter=lpr
o.Application.ActivePrinter=lpr


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