MS Excel: Set the ActivePrinter Error (HRESULT: 0x800A03EC)

grazzman

New member
Joined
Nov 25, 2003
Messages
3
Location
Berlin (Germany)
Hi from Germany!

I have a little Problem with Excel Automation.

Example:

Dim objWordApplication As New Microsoft.Office.Interop.Word.ApplicationClass()

objWordApplication.ActivePrinter = "Acrobat Distiller" --- NO PROBLEMS

...

objWordApplication.Quit()


Dim objExcelApplication As New Microsoft.Office.Interop.Excel.ApplicationClass()

objExcelApplication.ActivePrinter = "Acrobat Distiller" --- ERROR at Microsoft.Office.Interop.Excel.ApplicationClass.set_ActivePrinter(String RHS): HRESULT: 0x800A03EC ---

So, Ive tried this:

objExcelApplication.ActiveWorkbook.PrintOut(ActivePrinter:="Acrobat Distiller") --- ERROR at Microsoft.Office.Interop.Excel.ApplicationClass.set_ActivePrinter(String RHS): There are no Printers installed ---


I dont know what to do... Please help :(
 
Show the excel app. When the "Stop" messagebox shows, actually change the printer to the one you want in the excel document, and see what strPrinter returns. On mine it is "Acrobat Distiller on Ne01:".


Code:
objExcelApplication.Visible = True

MessageBox.Show("Stop")

Dim strPrinter As String = xlApp.ActivePrinter

MessageBox.Show(strPrinter)

objExcelApplication.ActivePrinter = strPrinter
 
Dim strPrinter As String = xlApp.ActivePrinter (I think you meant objExcelApplication.ActivePrinter)

Result: strPrinter = "There are no Printers installed [...]"

Maybe its a bug, I dont know :confused:
 
Originally posted by grazzman
Dim strPrinter As String = xlApp.ActivePrinter (I think you meant objExcelApplication.ActivePrinter)

Result: strPrinter = "There are no Printers installed [...]"

Maybe its a bug, I dont know :confused:

Yep, objExcelApplication.ActivePrinter is what I meant for your stuff.

Here is my code. I added a COM reference to the "Microsoft Excel 10 Object Library"

Code:
        Get the Excel Application ready
        Dim xlApp As Excel.Application
        xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
        xlApp.Visible = True
        xlApp.DisplayAlerts = False

        Get the Excel Workbook ready
        Dim xlBook As Excel.Workbook
        xlBook = CType(xlApp.Workbooks.Add, Excel.Workbook)


        PRINTER STUFF
        MessageBox.Show("Stop")
        Dim s As String = xlApp.ActivePrinter
        MessageBox.Show(s)
        xlApp.ActivePrinter = s

        xlApp.Quit()
        xlApp = Nothing

        GC.Collect()

P.S. Sometimes Excel has a hard time closing. Make sure youve killed all "Excel.exe"s from task manager.
 
Back
Top