By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

Word Automation - Setting ActivePrinter changes System Default

P: n/a
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
Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Try the following:

With Dialogs(wdDialogFilePrintSetup)
.Printer = strPrinter ' strPrinter is the name of the printer
(instead of setting ActivePrinter)
.DoNotSetAsSysDefault = True ' Doesn't change the system default
printer
.Execute ' Carries out the changes using the FilePrintSetup dialog
but without displaying it
End With

I haven't got Word 2003 to test this, but I hope you have success with
it.

MA
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.