[Resolved] VB6 is creating corrupted Excel 2007 instances
I create reports in Excel from my VB6 exe's. I've done it for years with no problems until Office 2007 came along. The following code fails when it tries to save the workbook (I simplified the code). If I stop the code prior to the 'SaveAs' line and try to save the workbook manually, it still fails. The error in both cases is "-2147417851 Automation Error. The server threw an exception". Its almost as if VB creates a corrupted Excel instance. I can manually do anything to the created instance, but when I try to save it, it fails.
I thought it might be because I am living in the Stone Age (VB6), so I tried it with the free VB 2008. It still fails.
The code only fails on a client PC. It works fine on my development PC (where VB6 is installed). There is something the VB6 install does that prevents the error.
I've tried late and early binding.
Here's the code that fails.
-----------------------------------------------
Dim lx_ExcelApp As Object
lx_ExcelApp = CreateObject("Excel.Application")
lx_ExcelApp.Application.Visible = True
lx_ExcelApp.Application.DisplayAlerts = False
lx_ExcelApp.Workbooks.Add()
lx_ExcelApp.ActiveWorkbook.SaveAs(FileName:="x.xls")
-----------------------------------------------
This is a real show stopper for me. I have searched the Web for weeks looking for a solution (other than installing VB6 on everyclient). PLEASE HELP!!!
Re: VB6 is creating corrupted Excel 2007 instances
Do you use a setup package to install your app on the client PC?
Re: VB6 is creating corrupted Excel 2007 instances
Try
Code:
Dim lx_ExcelApp As Object
Set lx_ExcelApp = CreateObject("Excel.Application")
:wave:
Re: VB6 is creating corrupted Excel 2007 instances
Quote:
lx_ExcelApp.Workbooks.Add()
lx_ExcelApp.ActiveWorkbook.SaveAs(FileName:="x.xls")
i can't test. but try setting the workbook to an object
vb Code:
set wb = lx_ExcelApp.Workbooks.Add()
wb.SaveAs(FileName:="x.xls")
also check if you need to supply some other parameters, such as the file type, to match the xls extension
Re: VB6 is creating corrupted Excel 2007 instances
Thanks, but nothing helped.
Again, it appears that VB is creating a corrupted Excel instance even before it creates a new workbook. If I only do the following:
Dim lx_ExcelApp As Object
set lx_ExcelApp = CreateObject("Excel.Application")
lx_ExcelApp.Application.Visible = True
lx_ExcelApp.Application.DisplayAlerts = False
MsgBox "stop"
When I manually open a new workbook in the created Excel instance, Excel fails. If I let VB create a new workbook, I get this incredibly informative message from VB: "Method '~' of object '~' failed".
Thanks for the help
Re: VB6 is creating corrupted Excel 2007 instances
does the client have adequate permissions, to access the appropriate folders from the created object?
Re: VB6 is creating corrupted Excel 2007 instances
A digital signature app (ApproveIt) was causing it. Now I need a patch from Silanis.
Thanks