Results 1 to 4 of 4

Thread: Excel Object Crashes non-XP systems

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2003
    Location
    New York City Baby!
    Posts
    18

    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?

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    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"

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2003
    Location
    New York City Baby!
    Posts
    18
    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?

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    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
  •  



Click Here to Expand Forum to Full Width