Word Automation - Setting ActivePrinter changes System Default

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stephen Barrett

    #1

    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
    DoNotSetAsSysDe fault flag set to True. For example, instead of using the
    following code:
    Set oWord = CreateObject("W ord.Application ")
    oWord.ActivePri nter = "HP LaserJet 4 on LPT2"

    Use the following:
    Set oWord = CreateObject("W ord.Application ")
    oWord.WordBasic .FilePrintSetup Printer:="HP LaserJet 4 on LPT2", _
    DoNotSetAsSysDe fault:=1
    ------------------------------------------------

    The problem I have is that this is VB script to be used in ASP or VB6. In
    C#, the Word.Applicatio n.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


  • MarkAAinsworth

    #2
    Use Word dialogs to change printer

    Try the following:

    With Dialogs(wdDialo gFilePrintSetup )
    .Printer = strPrinter ' strPrinter is the name of the printer
    (instead of setting ActivePrinter)
    .DoNotSetAsSysD efault = 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 **
    ----------------------------------------------------------
    Best Usenet Service Providers 2026 ranked by Newsgroup Access Newsservers, Usenet Search, Features & Free Trial. Add VPN for privacy.

    Comment

    Working...