Excel Automation error. The object invoked has disconnected

About the programming interface for the virtual PDF printer driver.

Moderator: jr

Excel Automation error. The object invoked has disconnected

Postby RobWEllis » Sat Aug 08, 2009 5:55 pm

Hi,

I have a routine in Excel which creates a PDF report of a few sheets within a workbook.

Most of the time it works fine but on one machine (XP SP3 and Excel 2003 SP3) it fails with "Automation error. The object invoked has disconnected " on the Sheets.PrintOut line.

I've included the code below in case it helps. Nothing special except that I use CreateObject("BullZip.PDFPrinterSettings") rather than having a reference to the BullZip dll because some of our machines don't have bullzip installed.

Thanks for looking!

Rob

[Code]
Function PrintToPDF(szSheetsToPrint() As String) As Boolean
PrintToPDF = False

Rem -- Get the full name of the printer
Dim szPDFPrinterName As String
szPDFPrinterName = GetFullNetworkPrinterName(FindPrinter("BullZip"))
If Len(szPDFPrinterName) > 0 Then
' Create the object to control the printer settings
On Error Resume Next
Dim oPrinterSettings As Object
Set oPrinterSettings = CreateObject("bullzip.PDFPrinterSettings")
If Err = 0 Then
' Write the settings to the printer. Settings are written to the runonce.ini whic is deleted immediately after being used.
szGeneratedFileName = ReplaceFileExtension(ActiveWorkbook.FullName, "pdf")
With oPrinterSettings
.setValue "output", szGeneratedFileName
.setValue "showsettings", "never"
.setValue "showpdf", "never"
.WriteSettings True
End With

' Delete file if it already exists
On Error Resume Next
Kill szGeneratedFileName
On Error Resume Next

' Change to PDF printer, print and then change back again
Dim szCurrentPrinter As String
szCurrentPrinter = ActivePrinter
ActivePrinter = szPDFPrinterName
Sheets(szSheetsToPrint).PrintOut
ActivePrinter = szCurrentPrinter
PrintToPDF = (Err <> 0)
End If
End If
End Function
[/Code]
RobWEllis
 
Posts: 6
Joined: Sat Aug 08, 2009 5:23 pm

Re: Excel Automation error. The object invoked has disconnected

Postby RobWEllis » Thu Aug 27, 2009 2:41 pm

I guess by the lack of response that I'm alone in this one.

Rob
RobWEllis
 
Posts: 6
Joined: Sat Aug 08, 2009 5:23 pm

Re: Excel Automation error. The object invoked has disconnected

Postby jr » Wed Sep 02, 2009 8:26 am

In which line of code does the error happen?

Regards,
Jacob
jr
Site Admin
 
Posts: 491
Joined: Sun Mar 26, 2006 12:28 pm

Re: Excel Automation error. The object invoked has disconnected

Postby RobWEllis » Thu Jun 17, 2010 3:30 pm

Hi Jacob,

Sorry for the huge delay in coming back to you but this problem still exists.

The line of code that fails is Set oPrinterSettings = CreateObject("bullzip.PDFPrinterSettings")

Thanks

Rob
RobWEllis
 
Posts: 6
Joined: Sat Aug 08, 2009 5:23 pm


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron