Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem about Excel references library in VB6

Status
Not open for further replies.

acjeff

Programmer
Aug 10, 2004
148
US
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
 
acjeff,

Should it be vbMaximized instead?

ObjExcel.WindowState = vbMaximized

vladk
 
No, not only the xlMaximized statement error. In fact, when I have no Excel object library reference, many functions are causing errors. For example:

objWorkSheet.Orientation = xlLandscape
chOjbect.Chart.ChartType = xlXYScatterSmooth
chOjbect.Chart.SeriesCollection(2).ChartType = xlXYScatter
chOjchOjbect.Chart.Axes(xlCategory)
chOjchOjbect.Chart.Axes(xlValue)

All the above built-in excel functions are causing "variables not defined" error. That why I have to find a way to well handle the object library reference missing problem. Please help.
 
can you have an app that runs excel functions without having excel on a computer? I didn't think you could.
 
Of course, I don't have any. I am wondering if I could package any Excel library with my VB application so that the user doesn't need to have Excel application and the program could still export data and create xls files. I am finding the way.
 
Your license agreement will tell you whether or not you may redistribute it. In this case it is highly doubtful, although I do not know for sure.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top