The Application object has a Version property that returns the version number (and sometimes letters) of the Excel instance that’s running.
Application.Version
Version always returns a string, but VBA can convert it to a number without much fuss. Unless, that is, the version number contains nonnumerical characters. In my Excel97, Application.Version returns 8.0e.
If you need to test the version to, for instance, stop the program for unsupported versions, you can use the Val function to just get the number.
If Val(Application.Version) < 9 Then
MsgBox “You must have Excel 2000 or higher”
Else
‘Do other stuff
End If
that’s good Dick, i didn’t know about Val, I’ll take a look at that, I’ve used thie in the past:
If Left(Application.Version, 1) >= 9 Then
oook!
Wel, there is also a build property that gives you what comes after the period in the version number. Because with Office XP, version gives you 10.0, even if you have Service Pack 3, which should read 10.6501.6626… In that case, build gives you 6501. Useful if you get the integrity problem with pivot tables when you protect/unprotect sheets/workbooks with VBA, in which case you need SP 3 installed to get rid of the bug.
So I used:
if application.build < 6501 then
msgbox “Try to run Office Update once in a while…”
end if
Hi I have a problem of PIVOT Table integrity. I have excel build 6355 and version 11. However, when other users with excel 2000 profession or excel 2002/xp opens this excel and save it, it gets corrupted. When I open the file it says Unable to read the file and after it says excel has repaired this workbook and disabled following Pivot tables features.
Let me know the solution for this.
Thanks,
HiREN.
I am using:
Mid(Application.Version, 1, InStr(Application.Version, “.”) – 1)
Thanks,
Sanjoy Roy
And after Sanjoy imparted that little gem, everything went eerily quiet…