|
-
Nov 6th, 2009, 05:55 PM
#1
Thread Starter
New Member
[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!!!
Last edited by BillEarl; Nov 8th, 2009 at 05:00 PM.
-
Nov 6th, 2009, 06:18 PM
#2
Re: VB6 is creating corrupted Excel 2007 instances
Do you use a setup package to install your app on the client PC?
-
Nov 6th, 2009, 07:03 PM
#3
Re: VB6 is creating corrupted Excel 2007 instances
Try
Code:
Dim lx_ExcelApp As Object
Set lx_ExcelApp = CreateObject("Excel.Application")
-
Nov 7th, 2009, 05:41 AM
#4
Re: VB6 is creating corrupted Excel 2007 instances
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 8th, 2009, 01:39 PM
#5
Thread Starter
New Member
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
-
Nov 8th, 2009, 03:00 PM
#6
Re: VB6 is creating corrupted Excel 2007 instances
does the client have adequate permissions, to access the appropriate folders from the created object?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 8th, 2009, 04:56 PM
#7
Thread Starter
New Member
Re: VB6 is creating corrupted Excel 2007 instances
A digital signature app (ApproveIt) was causing it. Now I need a patch from Silanis.
Thanks
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|