OL98: How to Programmatically Determine the Version of Outlook

ID: Q238404


The information in this article applies to:
  • Microsoft Outlook 98


SUMMARY

There may be times when your Outlook solution needs to determine which version of Outlook is currently running so that your code can take appropriate action. This article describes an approach you can use to accomplish this.


MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
The Outlook 98 object model does not provide a direct way of determining the installed version of Outlook. This functionality has been added to the Outlook 2000 object model, where the Application object has a Version property.

To Use the OutlookVersion Property

The approach below creates a temporary Outlook item and obtains the version number using the OutlookVersion property. Then the temporary item is deleted. One advantage of using this approach is that it will work in situations where any version of Outlook may be installed on the system.

Function CheckOLVersion()

   Dim dblVersion
   Dim objTestItem

   ' Create a temporary mail message
   Set objTestItem = Application.CreateItem(0)

   ' Save the message so the OutlookVersion property is set.
   objTestItem.Save

   ' Obtain the version of Outlook
   dblVersion = CDbl(objTestItem.OutlookVersion)

   ' Set the function value accordingly.
   ' (You can't use comparison operators with Select Case in VBScript)
   If dblVersion < 8.5 Then
      CheckOLVersion = "97"
   ElseIf dblVersion < 9.0 Then
      CheckOLVersion = "98"
   Else
      CheckOLVersion = "2K"
   End If

   ' Delete the temporary mail message
   objTestItem.Delete

   Set objTestItem = Nothing

End Function 
You would typically call this Visual Basic function from your code in the following manner:


Select Case CheckOLVersion
   Case "97"
      ' Insert "Outlook 97" code here
   Case "98"
      ' Insert "Outlook 98" code here
   Case "2K"
      ' Insert "Outlook 2000" code here
End Select 
IMPORTANT: This solution is only designed to work with the three versions of Outlook specified in the previous sample code. Future releases of Outlook will require modification to the code in order to distinguish that version from Outlook 2000.


REFERENCES

For additional information about creating solutions with Outlook, click the article numbers below to view the articles in the Microsoft Knowledge Base:

Q180826 OL98: Resources for Custom Forms and Programming
Q182349 OL98: Questions About Custom Forms and Outlook Solutions

Additional query words: OutSol OutSol98 vbscript 98

Keywords : OffVBS
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: January 5, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.