Preoblems with ActivePrinter when used with Automation from another program

B

Bogdan Zamfir

Hi,

I have a program in VFP which needs to automate word to print some
documents.
I need that documents to be printed on a specific printer, selected by
users.
So in automation code I assign printer name to ActivePrinter, call printout
and restore previous printer

My code is shown below

lcWrdPrint = wrd.ActivePrinter

(1*) wrd.ActivePrinter = lcPrinter && variable storing desired
printer name

wrd.DisplayAlerts = 0 && wdAlertsNone
odoc.PrintOut(.f.)
wrd.DisplayAlerts = -1 && wdAlertsAll
wrd.ActivePrinter =lcWrdPrint

This code works very well if run from a Word macro SUB (without VFP
comments, of course)
But if I run it from VFP, for some printer names (which, BTW, works VERY
WELL when used from Word), I get a runtime error in line (1*)

One such Printer name is
"Auto Lexmark1170 Series on MY-SERVER"

This is exactly the printer name as in Control Panel -> printers,. It was
assigned automatically by Windows when I connect to the network printer
But if I use it from Word sub, it works

However, if I rename it to something different , like
"Lexmark1170 Series MY-SERVER", it works from VFP too

Does anyone encountered this strange behavior?

Any solution or suggestion?

So far, I catch the error and display a warning msg for user, and recommend
him to rename the printer, but this is not a long-term solution

Thank you.

Best regards,
Bogdan Zamfir
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top