Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Determine version of Excel in VBA

I'd like to my macro to execute a certain sub if the user is using Excel
2003, and execute another sub if the user is using Excel 2007, both called
from the same shortcut key. Possible?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Determine version of Excel in VBA

Sub whatversion()
MsgBox Application.Version
End Sub

if application.version=11 then
do this
else
do that
end if

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"John" wrote in message
...
I'd like to my macro to execute a certain sub if the user is using Excel
2003, and execute another sub if the user is using Excel 2007, both called
from the same shortcut key. Possible?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Determine version of Excel in VBA

John

I'm afraid I don't know the version number for 2007 but 2003 is 11.0 so
something like this

If Application.Version = 11 Then
'Excel2003
'do 2003 macro
MsgBox Application.Version

Else
'check for 2007 version number
'do 2007 things
End If


Mike

"John" wrote:

I'd like to my macro to execute a certain sub if the user is using Excel
2003, and execute another sub if the user is using Excel 2007, both called
from the same shortcut key. Possible?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Determine version of Excel in VBA

If Val(Application.Version) < 12 Then
'You use Excel 97-2003
Else
'You use Excel 2007
End If

If this post helps click Yes
---------------
Jacob Skaria


"John" wrote:

I'd like to my macro to execute a certain sub if the user is using Excel
2003, and execute another sub if the user is using Excel 2007, both called
from the same shortcut key. Possible?



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Determine version of Excel in VBA


You can use code like the following:

Dim Ver As Long
Ver = CLng(Application.Version)
If Ver = 12 Then
' Excel 2007 or later
Else
' Excel 2003 or earlier
End If

Note, though, that any code the uses objects or methods that are new
to Excel 2007 will fail to compile and run in 2003. You'll get
compiler errors on those methods, even if you never execute them in
2003 and earlier.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Tue, 12 May 2009 07:11:57 -0500, "John" wrote:

I'd like to my macro to execute a certain sub if the user is using Excel
2003, and execute another sub if the user is using Excel 2007, both called
from the same shortcut key. Possible?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I determine if a version of Excel 2007 is professional? Kevin Excel Discussion (Misc queries) 2 June 11th 08 01:44 PM
determine Dll version am A. Excel Programming 2 October 2nd 06 10:44 PM
Fw: determine Dll version am A. Excel Programming 0 October 2nd 06 10:42 PM
How to determine Office version VanS[_2_] Excel Programming 5 March 3rd 05 07:47 PM
Determine version of .xls file from VB6 Wozza Excel Programming 0 October 14th 04 01:41 PM


All times are GMT +1. The time now is 04:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"