VB opens wrong version of Excel

I am attempting to write a VB app which opens Excel spread sheets.

The code:

Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlApp.Workbooks.Open ("C:\temp\yadata.xls")

does sort of work.   The issue is that we have both version 5 and 97 on our PCs.  Version 5 is required by PeopleSoft (only) and everything else uses 97.
The issue is that  the code opens up version 5.0. All of the playing around that I've tried (such as trying to hard code paths) gives syntax errors.

How do I make it start up 97 not 5.0?
quantzAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
Try this:
Set xlApp = CreateObject("Excel.Application.8")
0
 
riduceCommented:
Make sure you mark the reference Microsoft Excel 8.0 Object Library
0
 
Éric MoreauSenior .Net ConsultantCommented:
If xlApp is defined as Object, there is no need to reference Excel. I know this is not a good practice to declare as Object but it might help when dealing with multiple version!
0
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.

All Courses

From novice to tech pro — start learning today.