473,395 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Word Automation - Setting ActivePrinter changes System Default

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
1 10569
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jason Steeves | last post by:
I am hoping someone can tell me how, or point me in the right direction for the following problem. I need to have word open a specified file, .mht, as a plug-in inside of IE so that I can edit...
2
by: Joe Black | last post by:
Hi My database is filling a Word docs with data using bookmarks. My client wants one particular document to print using the lower tray which will hav a special letterhead loaded in it. Is...
4
by: Daniel | last post by:
Hello, i have a problem with the word automation from c#. First, i want to mention, that i don't have any dependencies from word in my c#-project, i want to use the system.reflection model to...
4
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that created document to an SQL Server database. Has anyone...
5
by: CJ Taylor | last post by:
I've been looking everywher efor this but all I can find is that Word's automation library doesn't allow you to pick a printer programatically... Anyone know of a soluition? Thanks, cJ
2
by: Vivek | last post by:
Hi, I have an application that writes to a word document. After that I wish to print the document to a particular printer automatically. I tried but it keeps on printing to the default...
1
by: Stephen Barrett | last post by:
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...
3
by: tigrrgrr42 | last post by:
I am working(vb.net03and05) with word documents stored in a sql db and I am currently bringing them from a byte array into a temp file to pop into word and make word do its thing as a com object. ...
13
by: kbperry | last post by:
Hi all, Background: I need some help. I am trying to streamline a process for one of our technical writers. He is using Perforce (version control system), and is constantly changing his word...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.