Verify excel Version upon opening or closing

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,077
Hello all,

Is there any way to add something to my opening or closing code that would check what version of excel is being used?
I have a number of features that won't work with Excel 2003 or below, and they are critical features, so I just don't want the workbook to be used in Excel that's older than 2007 (Sorry Clippy).

Is this doable in someway?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Application.Version

Still, you need to be careful with compile errors
 
Upvote 0
Try something like this out...you can replace the msgbox code for what you want to do...
Code:
[COLOR=#0000ff]Sub[/COLOR] ReturnExcelVersion()


[COLOR=#0000ff]    Select Case[/COLOR] Application.Version
    
       [COLOR=#0000ff] Case[/COLOR] "16.0": MsgBox "You are using Excel 2016."
        [COLOR=#0000ff]Case[/COLOR] "15.0": MsgBox "You are using Excel 2013."
        [COLOR=#0000ff]Case[/COLOR] "14.0": MsgBox "You are using Excel 2010."
        [COLOR=#0000ff]Case[/COLOR] "12.0": MsgBox "You are using Excel 2007."
        [COLOR=#0000ff]Case[/COLOR] "11.0": MsgBox "You are using Excel 2003."
        [COLOR=#0000ff]Case[/COLOR] "10.0": MsgBox "You are using Excel 2002."
       [COLOR=#0000ff] Case[/COLOR] "9.0": MsgBox "You are using Excel 2000."
      [COLOR=#0000ff]  Case[/COLOR] "8.0": MsgBox "You are using Excel 97."
        [COLOR=#0000ff]Case[/COLOR] "7.0": MsgBox "You are using Excel 95."
      [COLOR=#0000ff]  Case [/COLOR]"6.0": MsgBox "You are using Excel 6."
        [COLOR=#0000ff]Case [/COLOR]"5.0": MsgBox "You are using Excel 5."
        
[COLOR=#0000ff]    End Select[/COLOR]

[COLOR=#0000ff]End Sub[/COLOR]
 
Last edited:
Upvote 0
So if I do this:

Code:
If Application.Version > 11 ThenMsgBox "good"
'nothing happens - continue opening procedure
Else
MsgBox "bad"
'end sub, workbook still locked
End If

Should this be ok? I believe that version 12 is 2007. This is sometimes difficult to test out properly. but I have autoclose procedures that lock the sheets except for one. then my open procedure only runs if macros are enabled, and I want to make sure that there is a proper version installed.
 
Upvote 0
yes but you still need to be careful with compile errors... I would recommend you do the version check in the ThisWorkbook Module and then the rest of your codes should be located in seperate modules.
 
Last edited:
Upvote 0
I do have the version check in ThisWorkbook. And sure enough I got a compile error...:eek: I'll try removing the remainder of the code to another module and go from there...

Out of curiosity, do you know why that is? I just don't understand why checking the version needs to be all on its own.
 
Last edited:
Upvote 0
Out of curiosity, do you know why that is? I just don't understand why checking the version needs to be all on its own.

The vba compiler seems to compile each Module separately
 
Upvote 0
Ok, thanks!

Is there anybody using Excel 2003 that could make sure that this will properly close the workbook? I'd assume it will work, but idk...?:confused:

Code:
Private Sub Workbook_Open()If Application.Version > 11 Then
'Application.Run "Module13.NextOpen"
MsgBox "good"
Else
MsgBox "I'm sorry, your version of Excel is not supported by the scheduler." & vbNewLine & _
"Please use Excel 2007 or later. This file will now close", vbCritical, "The Friendly Scheduling Robot Says:"
ActiveWorkbook.Close SaveChanges:=False
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,752
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top