Results 1 to 1 of 1

Thread: Set Excel.ActivePrinter correctly

  1. #1

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Set Excel.ActivePrinter correctly

    Hey all,
    I'm trying to send an excel worksheet to an arbitrary printer but I don't know how to get the complete name of the printer that excel needs.

    I have a printer and it's name is "Server Copier". When I set it to the default printer and I look at the excel app's ActivePrinter property, it is "Server Copier on Ne00:". If I change the default to another the ActivePrinter settings is "<printerName> on Ne01:"

    So if I have a printer name (from a printer dialog) how do I get the fully qualified name to set the ActivePrinter? Setting the ActivePrinter to just the printer name results in an interop exception.
    thanks
    kevin
    vb.net Code:
    1. Dim xlApp As Excel.Application = Nothing
    2.         Dim xlWorkBook As Excel.Workbook = Nothing
    3.         Dim xlWorkSheet As Excel.Worksheet = Nothing
    4.  
    5.         xlApp = New Excel.Application
    6.         xlApp.DisplayAlerts = False
    7.         xlWorkBook = xlApp.Workbooks.Open(fName)
    8.  
    9.  
    10.         'xlApp.Visible = True
    11.         xlApp.Visible = False
    12.  
    13.         xlApp.ActivePrinter = printerName
    Last edited by kebo; Jul 31st, 2017 at 08:40 PM. Reason: added code
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width