Bug setting Printer using VBA under TS

R

Richard M.

Hi,

I have some Word VBA code which sets the active printer.
It will not work on printers that are not directly
connected to the client. It will yeld an error "Run-time
error '5216'. There is a printer error".

The printer is OK and you can print directly on it from
Word.

I was able to establish that the bug is triggered by the
following syntax in printer name :
" 'printer name' on 'computer' (from 'computer') in
session 1"
(The typical name for printers remapped in a TS session
when the TS client map a shared printer.)

For instance if the printer is seen in the TS session as :
"LaserJet 2100 on A (from B) in session 1"
it will trigger the problem.

But, if I rename the printer in the "Printer and Faxes"
and try to set the printer in VBA, for instance as :
"LaserJet 2100 xx A (from B) in session 1", it will work
flawlessly. (And it will print fine too.)

I don't know what happends behind the curtain, but I
guess that some magic is at work there.
If you set the printer and read it back, you get
additional information on the session.
For instance :
ActivePrinter="LaserJet 2100 xx A (from B) in session 1"
?ActivePrinter
LaserJet 2100 xx A (from B) in session 1 on TS003

Notice the "on TS003"
I guess this explain why the "on A" is confusing the
printer set up.
From my understanding, Word analyze the printer name
string and add a "port" name is not present.
But when it encouters the "on A" it tries to identify "A"
as a session name.

If I define the printer string as
"LaserJet 2100 on A (from B) in session 1 on TS003", it
will work. (Since the "on TS003" is present, VBA will use
it as the correct port name.)

The trouble is that I will not be able to get the "TS003"
part from my code.

To me, the problem is unique to the TS plateform because
only in that environement you get the "on computer1" part
in the printer name.

Is this problem known ?
What do you suggest as a workaround ?

I am using Win2K3 EE TSE, Office 2000 EN SP3.

Thanks,

--Richard. (rim at wanadoo dot fr)
 

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