Verify excel Version upon opening or closing

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,067
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?
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
7,493
Office Version
2016
Platform
Windows
Application.Version

Still, you need to be careful with compile errors
 

mrmmickle1

Well-known Member
Joined
May 11, 2012
Messages
2,453
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:

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,067
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.
 

mrmmickle1

Well-known Member
Joined
May 11, 2012
Messages
2,453
Exactly. That should do the trick.
 

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
7,493
Office Version
2016
Platform
Windows
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:

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,067
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:

Jaafar Tribak

Well-known Member
Joined
Dec 5, 2002
Messages
7,493
Office Version
2016
Platform
Windows
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
 

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,067
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
 

Forum statistics

Threads
1,082,305
Messages
5,364,401
Members
400,800
Latest member
germanpbv

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top