Hi all,
I use VB6 application to data from Access database to Excel worksheet. The problem is the error when a user's machine does not have any version of Excel application.
First, in my VB project references, I check the box Microsoft Excel 8.0 Object Library. Then, my code is like this:
Dim ObjExcel As Object
Dim ObjWorkBook As Object
Dim ObjWorkSheet As Object
Set ObjExcel = CreateObject("Excel.Application")
If ObjExcel Is Nothing then Exit Sub
Set ObjWorkBook = ObjExcel.Workbooks.Add
Set ObjWorkSheet = ObjWorkBook.ActiveSheet
ObjExcel.WindowState = xlMaximized
When there is Excel installed (from Excel 97 to Excel 2003), the reference library changes from 8.0 to 11.0 automatically, and the program works fine. However, when there is no Excel in the computer, the reference library is missing and causing error. I did put checking statement (like the above) to avoid error but it still saying "variable not define" on xlMaximized statement.
Is there any way to resolve this reference library problem?
Please help, urgent!
Jeff
I use VB6 application to data from Access database to Excel worksheet. The problem is the error when a user's machine does not have any version of Excel application.
First, in my VB project references, I check the box Microsoft Excel 8.0 Object Library. Then, my code is like this:
Dim ObjExcel As Object
Dim ObjWorkBook As Object
Dim ObjWorkSheet As Object
Set ObjExcel = CreateObject("Excel.Application")
If ObjExcel Is Nothing then Exit Sub
Set ObjWorkBook = ObjExcel.Workbooks.Add
Set ObjWorkSheet = ObjWorkBook.ActiveSheet
ObjExcel.WindowState = xlMaximized
When there is Excel installed (from Excel 97 to Excel 2003), the reference library changes from 8.0 to 11.0 automatically, and the program works fine. However, when there is no Excel in the computer, the reference library is missing and causing error. I did put checking statement (like the above) to avoid error but it still saying "variable not define" on xlMaximized statement.
Is there any way to resolve this reference library problem?
Please help, urgent!
Jeff