|
-
Jul 21st, 2003, 04:01 PM
#1
Thread Starter
Junior Member
Excel Object Crashes non-XP systems
I am creating an Excel object in my VB6 app. My development machine has Excel 10 (XP), and so I set a reference to "Mcirosoft Excel 10 Library" and then do this:
Dim xl As Excel.Application
Private Sub Form_Load()
Set xl = New Excel.Application
xl.Workbooks.Open (App.Path & "\myfile.xls")
This works *great* on systems with Excel 10, but not on systems that have Excel 97 or 2k. Is there a way I can make this reference and ensure backward compatibility between my app and various versions of Excel? Do I need to install Excel 97 and make a reference to that instead? Hmmm.... Is there a way to make a generic reference to Excel without specifying a version?
-
Jul 21st, 2003, 04:42 PM
#2
Change your reference to the excel 8.0 object library(or 9.0 if you dont have the 8.0)
you may not have all the same functionality (if you used any features that are only in excel10)
but that will allow older version to work.
if that doesnt work..
use the createobject code
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jul 21st, 2003, 05:06 PM
#3
Thread Starter
Junior Member
ok, i changed it from:
Dim xl As Excel.Application
Private Sub Form_Load()
Set xl = New Excel.Application
to:
Dim xl As Object
Private Sub Form_Load()
Set xl = CreateObject("Excel.Application")
And now it works fine with the other versions of Excel. No more crashes!! Why the difference, even when the reference stays constant at "Microsoft Excel 10 Library"?
Hmmm... early vs late binding? Why? Why? Why?
-
Jul 21st, 2003, 05:23 PM
#4
its no longer using the reference....
it creating an Excel Object with whatever version is available on the machine
problem is...that way you dont get the popup of available code when your coding the app....if you can use a refernce to the 8.0 object library...that will work as well.
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
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
|