.net - COMException when assigning to Excel.Application.ActivePrinter -
i have function, i'm passing microsoft.office.interop.excel.application instance. function uses windows' built in fax printer, or microsoft xps document writer, save file tiff image.
however, when seek assign application's activeprinter property, comexception next message thrown:
exception hresult: 0x800a03ec
here's code:
'save current default printer dim strdefaultprinter string = excelapp.activeprinter 'assign printer string constant activeprinter - throws exception excelapp.activeprinter = fax_printer excelapp.activeworkbook.printoutex(, , , , , true, "c:\restoffilepath...") ' print file = true 'reset default printer excelapp.activeprinter = strdefaultprinter
the printers used confirmed installed/in registry. similar function takes word application class works fine. i'm pretty new com related stuff, , have feeling may excel-related ignorance @ play, can find nil relating when searching google/stackoverflow, except 1 or 2 old, unanswered threads. there few relate big amounts of data/large ranges, not activeprinter property
edit - brief summary of answer, detailed in m patel's link:
excel picky setting it's activeprinter property; instead of printer name alone, requires both printer , port, e.g. "fax on ne01:". port should available registry, either at:
hkey_current_user\software\microsoft\windows nt\currentversion\devices
or
hkey_local_machine\software\microsoft\windows nt\currentversion\devices
using method detailed in link, or in case using microsoft.win32.registry.getvalue(). latter homecoming along lines of "winspool,ne01:". concatenating lastly part of string on printer name in manner "fax on ne01:", allows activeprinter property set without exception.
i should note problem occurring in excel 2010
maybe link below help? looks formatting of name assign activeprinter property matters.
http://netindonesia.net/blogs/jimmy/archive/2011/02/25/how-to-change-the-active-printer-to-specific-printer-in-excel-using-net-and-how-the-heck-can-i-find-the-right-printer-name-and-port-combination-that-excel-wants.aspx
.net vb.net excel com comexception
No comments:
Post a Comment