Solved

WSH VBscript - How to determine MS Office version ?

Posted on 2004-04-12
6
2,036 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
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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

827 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