• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 647
  • Last Modified:

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?
0
doshoss
Asked:
doshoss
  • 3
  • 2
1 Solution
 
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now