I figured it out! There is a setting in Excel to disable add-ins. You have to add the Developer tab to the ribbon in MS Excel 2007. Then you go to Excel Options, then Add-ins. Check the box to disable add-ins.
WOOHOO!
I removed all references to Excel, and it doesn't work. I am using late binding, but this is in my existing project. I guess I will need to make up a dummy project.
Well, I put the ExcelApp.Visible before the Workbooks.Add code and it opens Excel, then throws the error on the Add line. The workbook sheet does open though.
FYI, the code bombs at this line:
Set WorkBook = ExcelApp.Workbooks.Add(xlWBATWorksheet)
That is consistent with my original code. It bombs at the Workbook.Add part. I will look at the GetObject and CreateObject link. Thanks!
dilettante,
A guy I work (with Excel 2007) with gets the same error when trying to run the .exe. But there is another person that has 2007 and doesn't have a problem.
strongm,
Are you compiling and running on the same machine? I am compiling on a machine with Excel 2003, and running on a...
Roy, I don't think any of those things are causing the problem. This app has worked well for years. Then I get Office 2007 on my computer and I get this error. It would seem to be a version dependency issue, but I'm not sure.
Ok, here you go.
Private Sub ThisReportInExcel
10 On Error GoTo ThisReportInExcel_Error
' Declare our Excel objects.
Dim MyCMD As New ADODB.Command
Dim param As ADODB.Parameter
Dim Myrs As ADODB.Recordset
Dim MyExcel As Object
Dim MyWorkbook...
Ok, I have declared all of the objects as Object and dropped the reference to the Excel Object Library. I still get the same error. Do I need to set the objects with CreateObject? I am only using CreateObject with the MyExcel object.
After searching I found out that I should change this line
Set MyExcel = New Excel.Application
to this
Set MyExcel = CreateObject("Excel.Application")
Is that all I need to do?
Andrjezek,
It does point to the Microsoft Excel 11.0 Object Library. Is that what is causing the error?
FYI, I have the code in line 70 (from your post) later in my code.
Line 50, the Set Workbook line.
10 Dim MyExcel As Object
20 Dim MyWorkbook As Object
30 Dim MyWorksheet As Excel.Worksheet
40 Set MyExcel = New Excel.Application
50 Set MyWorkbook = MyExcel.Workbooks.Add
60 Set MyWorksheet = MyWorkbook.ActiveSheet
I get this message when trying to open an excel file in my VB6 application. It just started happening since I got a new PC with Excel 2007 on it. The excel file is being built dynamically by the app.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.