XL2002: Application.Version Does Not Compare Versions as Expected (282034)



The information in this article applies to:

  • Microsoft Excel 2002

This article was previously published under Q282034

SYMPTOMS

When you compare the results of the Application.Version property to another string value, you receive an unexpected result.

For example, if you compare the results of the Application.Version property in Microsoft Excel 2002 to the number of an earlier version, such as "7.0", your code returns FALSE, as if Excel 2002 was not a later version than Excel 7.0.

CAUSE

Application.Version returns a String value instead of a numeric data type. Because the Excel 2002 version string is "10.0", the following line of code evaluates to FALSE:
Application.Version > "7.0"
				
In a string comparison, "10.0" is less than "7.0".

RESOLUTION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To evaluate the string returned by Application.Version as a number, use the Val function to convert the string to a number, as follows:
Val(Application.Version) > 7
				

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbprb KB282034