Is there a vba compiler constant (or expression) I can use to determine which version of Outlook is running?

Posted on 2008-11-12
Last Modified: 2012-08-14
I am writing an Outlook VBA script that uses 2007-specific methods and properties. At times, this script will need to run in an Outlook 2003 environment, in which case I don't need to use these methods & properties. I would like to use compiler constants to control their execution, but I have not been able to identify a compiler constant that will determine the version of Office or Outlook that is running. Can you provide some suggestions or a means to make this determination at compile time?
Question by:doshoss
    LVL 11

    Expert Comment


    will return the version, 11 is 2003, 12 is 2007
    LVL 76

    Expert Comment

    Application.Version returns thay information. The first part is the major release number. Mine is The 11 means 2003.

    Author Comment

    "Val(Application.Version)"   cannot be used at compile time in VBA. Doing so results in an "Invalid use of object" error message.  I need to be able to determine the version of Office or Outlook that is running at compile time, not run time. Is that possible?

    Kind regards

    LVL 76

    Accepted Solution

    Can you explain how you are compiling VBA? Surely procedures are always compiled as needed at run time.

    You can determine which version is running and any code that would produce an error in a particular version can be put in a version-sensitive procedure.

    Author Comment

    Thanks for you input...

    I always pre-compile my code using Debug-Compile, which will expose errors in references to properties and methods that are not version-available. You are correct in that I could choose NOT to do this and just depend on the run-time compile; however, this may prevent me from seeing other compiler errors.

    I have begun to go in the direction of placing version sensitive code in run-time, version checkable procedures as you have suggested... although it seems a bit like a bandaid. If I am understanding you, it is not possible to determine version at compile time... please confirm this if you have a chance.

    Alternatively, if you have a some insight into other ways to get clean pre-runtime compiles when referring to properties and methods that are not supported in the installed version of Outlook, I'm all ears.

    Kind regards,


    Author Closing Comment


    Thanks for your input. Ultimately, I was able to seperate the code into seperate modules by version calling the correct module as needed using the run-ime syntax you provided. That worked, and also taught me that VBA compiles modules only as needed. Previously, I had assumed that all modules were compiled at one time.

    I never did get a clear answer on whether version can be determined at compile time, but based on all my research, I'm assuming the answer is no.

    Kind regards,


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Learn more about the importance of email disclaimers with our top 10 email disclaimer DOs and DON’Ts.
    Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
    The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now