Solved

WSH VBscript - How to determine MS Office version ?

Posted on 2004-04-12
6
2,046 Views
Last Modified: 2012-06-27
Using WSH VBscript with MS Word and Outlook.  Need to know what version of Office in use so the "CreateObject" will not fail.  

Example that works with older versions of Outlook:

     Set objOL = CreateObject("Outlook.Application")

Syntax required by Office 2003:

    Set objOL = CreateObject("Outlook.Application.11")

Thanks for any ideas.
0
Comment
Question by:mistert006
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 10808896
This works for me:
Set objOL = CreateObject("Outlook.Application")
Msgbox objOL.version
Set objOL = Nothing
0
 

Author Comment

by:mistert006
ID: 10808913
I need to know the Outlook version before doing the "CreateObject" or it will fail.

Thanks
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 10808937
Good point, don't know.  You may have to search in the registry. Ouch!
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 17

Accepted Solution

by:
zzzzzooc earned 500 total points
ID: 10809110
Registry keys for them would be something such as below..

HKEY_CLASSES_ROOT\Outlook.Application
HKEY_CLASSES_ROOT\Outlook.Application.11

If the key exists, you should be able to create the object. There's also a CurVer sub-key that mentions which CLSID is the current one (updated one).

So within "Outlook.Application", if CurVer says "Outlook.Application.11", then it supports that.


Not sure if this helps or not.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 10809907
"Syntax required by Office 2003:   Set objOL = CreateObject("Outlook.Application.11")"

I have Office 2003 on my PC and I don't have to use that syntax.  The syntax below works just fine.

Set objOL = CreateObject("Outlook.Application")
Wscript.Echo objol.version
Set objOl = Nothing
0
 
LVL 14

Expert Comment

by:aelatik
ID: 10810765
Check it with a function :

If DetermineObject <> "" Then
  Dim X
  Set X = CreateObject(DetermineObject)
  MsgBox X.version
  Set X = Nothing
End If

Function DetermineObject()
  On Error Resume Next
  Dim NEW_OBJ: Set NEW_OBJ = CreateObject("Outlook.Application.11")
  Dim OLD_OBJ: Set OLD_OBJ = CreateObject("Outlook.Application")
  If IsObject(NEW_OBJ) Then
    DetermineObject = "Outlook.Application.11"
  ElseIf IsObject(OLD_OBJ) Then
    DetermineObject = "Outlook.Application"
  Else
    DetermineObject = ""
  End If
End Function
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

728 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