View Full Version : Solved: Only run this command if Excel version is above 2003

10-19-2011, 01:28 AM
I have this code in an .xls workbook designed for use primarily in 2007, in the selection change event (it works very well)

I've been using On Error Resume Next to avoid an error if the workbook is run in 2003,
but prefer to make changes to stay away from that.
** Checking the Excel version as shown below seems to work.
Would like opinions on whether or not this is the cleanest way to go.

If Application.Version >= "12.0" Then
If Not Application.CommandBars.Item("Ribbon").Height > 100 Then
'Ribbon is Minimized
'do nothing
' I don't know why but using If Not and Else is working more consitantly with send keys .
Application.SendKeys ("^{F1}")
'~~> Minimize Ribbon
End If
End If

10-19-2011, 02:11 AM
I would use:
If Val(Application.Version) >= 12 Then

10-19-2011, 02:29 AM
Thanks Aflatoon :friends: