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:
Dim xlApp As Excel.Application = Nothing
Dim xlWorkBook As Excel.Workbook = Nothing
Dim xlWorkSheet As Excel.Worksheet = Nothing
xlApp = New Excel.Application
xlApp.DisplayAlerts = False
xlWorkBook = xlApp.Workbooks.Open(fName)
'xlApp.Visible = True
xlApp.Visible = False
xlApp.ActivePrinter = printerName