Solved

WSH VBscript - How to determine MS Office version ?

Posted on 2004-04-12
6
2,012 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now