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

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?
doshossAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

thydzikCommented:
Val(Application.Version)

will return the version, 11 is 2003, 12 is 2007
0
GrahamSkanRetiredCommented:
Application.Version returns thay information. The first part is the major release number. Mine is 11.0.0.5608. The 11 means 2003.
0
doshossAuthor Commented:
"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

Dan
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

GrahamSkanRetiredCommented:
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.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
doshossAuthor Commented:
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,

Dan
0
doshossAuthor Commented:
Graham,

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,

Dan
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.