S
Stephen Barrett
I am doing word automation with Word 2003. Everything works great except
for one thing. When I set the word object's ActivePrinter to a different
printer, it changes the system default. I looked for help on MS site and
they say it is a known issue. The work around is to use WordBasic commands
like as follows.
------------------------------------
MORE INFORMATION
To select a new printer without having Word change the default system
printer, use the WordBasic FilePrintSetup method with the
DoNotSetAsSysDefault flag set to True. For example, instead of using the
following code:
Set oWord = CreateObject("Word.Application")
oWord.ActivePrinter = "HP LaserJet 4 on LPT2"
Use the following:
Set oWord = CreateObject("Word.Application")
oWord.WordBasic.FilePrintSetup Printer:="HP LaserJet 4 on LPT2", _
DoNotSetAsSysDefault:=1
------------------------------------------------
The problem I have is that this is VB script to be used in ASP or VB6. In
C#, the Word.Application.WordBasic property returns back a generic object.
I don't see any objects available that I can cast the object to to simulate
what MS suggests. Is there some kind of secret way to do this in .Net?
I thought about grabbing the default printer before I set the ActivePrinter,
then setting the saved value back to ActivePrinter after I print. I would
prefer to do it the proper way, but I can find the objects to do it.
Help?
SB
for one thing. When I set the word object's ActivePrinter to a different
printer, it changes the system default. I looked for help on MS site and
they say it is a known issue. The work around is to use WordBasic commands
like as follows.
------------------------------------
MORE INFORMATION
To select a new printer without having Word change the default system
printer, use the WordBasic FilePrintSetup method with the
DoNotSetAsSysDefault flag set to True. For example, instead of using the
following code:
Set oWord = CreateObject("Word.Application")
oWord.ActivePrinter = "HP LaserJet 4 on LPT2"
Use the following:
Set oWord = CreateObject("Word.Application")
oWord.WordBasic.FilePrintSetup Printer:="HP LaserJet 4 on LPT2", _
DoNotSetAsSysDefault:=1
------------------------------------------------
The problem I have is that this is VB script to be used in ASP or VB6. In
C#, the Word.Application.WordBasic property returns back a generic object.
I don't see any objects available that I can cast the object to to simulate
what MS suggests. Is there some kind of secret way to do this in .Net?
I thought about grabbing the default printer before I set the ActivePrinter,
then setting the saved value back to ActivePrinter after I print. I would
prefer to do it the proper way, but I can find the objects to do it.
Help?
SB