Rob Willoughby writes:
> Com-objects can be affected by user interaction or the printer not setup
the
> same as you have it in your code. Printing programmatically can add a
whole
> set of new ways to break your program. I know, since we sometime print
> from RF scanners and tablets, and also generate XLSX files and email to
users.
Excel uses the current printer to determine things like paper size
available, fonts available, and so on. Having NO printer selected causes
easily spotted errors like what was see the one time. Having a DIFFERENT
printer selected can cause font issues, availability of features, and so on,
like you are seeing. I have seen COM object failures when used with a less
capable printer selected. No code change, in fact, the code was in the
middle of a run when the default printer was changed. [I.e. push a button
for a report. Wait. Receive it. Change printer. Repeat and fail.]
Change your code. Do NOT assume the correct printer is selected. Add code
to save the current printer, then select the correct one. When the report
is done, reset the printer back to the saved value. Have an error exit if
the needed printer is not available. There are system variables with the
current printer and available printers. Interrogate them. For now, to
prove this is the issue, just add the current printer as an extra line of
text in the email after the body. Then if the failed reports have a strange
printer, you know why it fails and can fix.
/jeff
http://www.linkedin.com/pub/jeff-pilant/65/1a/462/