[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Open Excel xlsx using create object in vba excel

Posted on 2010-04-01
9
Medium Priority
?
1,962 Views
Last Modified: 2013-11-25
Both Excel 2003 and Excel 2007 are installed on a  machines
How to control the object version open when this script line is executed ?
Set appXL = CreateObject("Excel.Application")
i have xlsx file but it opens in excel 2003.
how to open in 2007 using vba.

thanks
yking
0
Comment
Question by:RAJ4U
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 29320534
It's as easy as adding the identifier:

'Set to 2003
'Set appXL = CreateObject("excel.application.11")
'set 2007
Set appXL = CreateObject("excel.application.12")

Chris
0
 
LVL 11

Expert Comment

by:jkpieterse
ID: 29320962
Chris: unfortunately, the version number in the createobject line is ignored.
yking: From what application are you running this code?
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 29321158
Jan

Why  do you say that ... I have just tested on two machines, 1 of each install and they error out on the uninstalled version but work with the correct version - indicating it does work.

Chris
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 85

Expert Comment

by:Rory Archibald
ID: 29321509
Chris,
If you have both versions on one machine, the version number is ignored as JK said. There is no way to specify which version you want loaded using Automation (that I know of) - you need to shell the version, then use GetObject to grab the file reference.
Rory
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 29321962
Jan / Rory

I'm rich enough to have 1 machine per version, (hah!, work machine and mine) so I haven't had the chance to experience that, at least that's something to pin down in my knowledge banks now - thanks

Chris
0
 

Author Comment

by:RAJ4U
ID: 29480098
hi kpieterse,
i am using access 2007  vba to launch the excel object.
0
 

Author Comment

by:RAJ4U
ID: 29480217
rorya,
if i opened xls in 2003 and launch using shell excel 2007 then which one it will take as get object.

0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 2000 total points
ID: 29566867
You pass the workbook name to getobject and then you get a reference to that workbook.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

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

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…

611 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