Solved

WSH VBscript - How to determine MS Office version ?

Posted on 2004-04-12
6
2,039 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
Independent Software Vendors: 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!

 
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

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!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

756 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