Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

detect Excel reference version to run specific code

Posted on 2014-02-02
2
Medium Priority
?
448 Views
Last Modified: 2014-02-02
hey guys,

i've got an Access application in an environment where some users run Microsoft Office 2003 and some 2007.

i compile my Access application in Access 2003 so that the references to Excel will be appropriately linked when the users open the application - either Excel 2003 or 2007.

as a result,

i need to run Excel 2003 specific code if the Excel reference is Microsoft Excel 11.0 Object Library

and

i need to run Excel 2007 specific code if the Excel reference is Microsoft Excel 12.0 Object Library

from what i've experienced so far (which is pertinent to my app), sort and pivot table code is different between the 2 versions.

Question 1) how do i detect what the Excel Object Library reference version is so that i can run the appropriate code?

Homework: Macro Shadow has kindly helped me before (and some of you wonderful experts as well!) and given me a solution that i can modify for this purpose, however it requires "Trust access to the VBA project object model"

this means that i must go to every computer to activate that option - which makes deployment and maintenance very difficult.

i am thinking of a workflow along the lines of

1) detect Excel Object Library version
2) select case based on version and run code

i think that's the right way to do it. however the "expedient way" which is both lazy and impatient (2 good qualities) is just to

1) run an On Error Goto / On Error Resume Next
2) then test for an error and then run the code from there

Question 2) what's the best way yall would advise me to do notwithstanding what i've mentioned?

thanks for your wonderful help as always guys!! = ))
0
Comment
Question by:developingprogrammer
[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 Comments
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 39827875
Hi,

maybe with

oXL = CreateObject("Excel.Application")
MsgBox oXL.Version

Open in new window

Regards
0
 

Author Comment

by:developingprogrammer
ID: 39828626
whao thanks Rgonzo1971! that works like a charm!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

636 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