Solved

VB opens wrong version of Excel

Posted on 2000-04-04
3
435 Views
Last Modified: 2011-08-18
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?
0
Comment
Question by:quantz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 50 total points
ID: 2685797
Try this:
Set xlApp = CreateObject("Excel.Application.8")
0
 
LVL 1

Expert Comment

by:riduce
ID: 2686419
Make sure you mark the reference Microsoft Excel 8.0 Object Library
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2686916
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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question