VBA using excel

Urgent:
I am running VB6 with SQL 7 as a backend on OS 2000/office 2002.  I use this piece of code to open excel.

Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet

    Set oXL = CreateObject("Excel.Application")
    Set oWB = oXL.Workbooks.Open(lblImportEnrollmentFile.Caption)   ' Get a new workbook.
    Set oSheet = oWB.ActiveSheet

lngBlankRow = oSheet.Cells.SpecialCells(xlCellTypeLastCell).Row      'Finds first blank row in Column A

I have to distribute my project to a Windows 98 machine using office 97.  
when i setup the VB application on the 98 machine i get an error :

"This program has performed an illegal operation and will be shut down.  if problem persists, contact the program vendor."


What does this mean?  Is there an issue with Excel not being able to open this way.  

JoannieJeffersonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wimthepimscakeCommented:
Hi JoannieJefferson,

take notice that office 97 is using another reference library than office 2000/2002 so you should also deploy this.
but actually this is a f***ed up error message and reminds me why win 98 sucked so much :-)

Wimthepimscake
0
ampapaCommented:
No, your code should work fine. What else is entailed in the "VB application"?
0
JoannieJeffersonAuthor Commented:
Wimthepimscake,

When i look in  Project/References in vb to add office 97 reference its not there.

I am new at this.....how and where do i find this reference.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

RichWCommented:
The reference would be there if you have Office 97 installed on your machine.  Wimthepimscake is correct.  Office 97 was VBA, and Office 2002 is VB 6.  They are two totally different animals.

If your Win 98 machines are running Office 97, I would suggest installing Office 97 on your machine and using that library instead.

RichW

0
ampapaCommented:
By late binding which is what you are trying to use in your application it should be independent of the Excel version you are trying to run it on.

Try changing:
Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet

    Set oXL = CreateObject("Excel.Application")
    Set oWB = oXL.Workbooks.Open(lblImportEnrollmentFile.Caption)   ' Get a new workbook.
    Set oSheet = oWB.ActiveSheet

To:

Dim oXL As object
Dim oWB As object
Dim oSheet As object

    Set oXL = CreateObject("Excel.Application")
    Set oWB = oXL.Workbooks.Open(lblImportEnrollmentFile.Caption)   ' Get a new workbook.
    Set oSheet = oWB.ActiveSheet
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JoannieJeffersonAuthor Commented:
That's it. And this is the section that it errors on.  

Set oXL = CreateObject("Excel.Application")
    Set oWB = oXL.Workbooks.Open(lblImportEnrollmentFile.Caption)   ' Get a new workbook.
    Set oSheet = oWB.ActiveSheet
0
JoannieJeffersonAuthor Commented:
in addition to my question....

I have an excel template that was created in office 2002 and is packaged with the setup.  
I also get an error when it trys to open the template.  How can I work around this?
0
ampapaCommented:
Glad it worked and that I could help.

Excel 97 probably won't be able to open a 2002 template just a guess unless you can make it backward compatible? I don't use templates so am unfamiliar with the territory...
0
Arthur_WoodCommented:
if you are trying to install this app on a PC that does NOT have at least Office 2002 installed, then any attempt to open the excel template (which was created with Office 2002) is ddoomed to failure.  A genearl guidleine when developing applications that will be used on multiple versions of some underlying software (be it the Operating system, or some other component) is to ALWAYS, without exception, use the LOWEST COMMON DENOMINATOR on your development box.  That measn that if you want your application to be able to run successfully on Windows 98 or newer, using Office 97 or newer, then your development box MUST be configured for Windows 98, and Office 97.

If you don't do that, then you are almost certainly going to fail when attempting to run your application on a version of the underlying software that is EARLIER (OLDER) than that on which you developed the application.  Microsoft has generally been pretyy godd about being 'backward' compatible - that is a application developed on an OLDER platform, will usually run under the newer version, but NOT THE OTHER WAY AROUND (newer software running on older platform).

AW
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.