[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 396
  • Last Modified:

How can I find out which version of excel and word the user has installed

Hi,

does anybody have a VBA code snippet for me, which tells me, which version of word and excel the user has installed?

Thanks!!!
0
rolandkg1001
Asked:
rolandkg1001
  • 9
  • 8
  • 2
  • +1
3 Solutions
 
torimarCommented:
Hi,

the command used is
Application.Version

Here's an example that also lists the Excel version numbers:
http://www.vbaexpress.com/kb/getarticle.php?kb_id=336

As to Word versions, refer to the Windows section on this page:
http://en.wikipedia.org/wiki/Microsoft_word#Versions
0
 
Shanmuga SundaramCommented:
to find the version of word, use the below given code in your application

Set wdapp = CreateObject("Word.Application")
MsgBox "The version of Microsoft Word installed is " & wdapp.Version

to find the version of Excel, use the below given code in your application
Set Excelapp = CreateObject("Excel.Application")
MsgBox "The version of Microsoft Excel installed is " & Excelapp.Version
0
 
rolandkg1001Author Commented:
Thanks to all!

I try your solutions....
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
Chris BottomleyCommented:
Hi it might be easier to create a file and call it for example versions.vbs.

Paste the folowing into it and then execute the file.  See the line:
    constapps = "Access, Excel, Word, Powerpoint"
 to expand/reduce the MS apps being checked

Chris
dim constApps 
Dim app
Dim strapp
dim appCount
dim ver
dim verstring
 
    constapps = "Access, Excel, Word, Powerpoint"
    strapp = Split(Replace(constApps, ", ", ","), ",")
    On Error Resume Next
    For appCount = 0 To UBound(strapp)
        Set app = CreateObject(strapp(appCount) & ".application")
        If app Is Nothing Then
            ver = strapp(appCount) & " not found"
        Else
            Select Case CInt(app.Version)
                Case 12
                    ver = "2007"
                Case 11
                    ver = "2003"
                Case 10
                    ver = "XP .. 2002"
                Case 9
                    ver = "2000"
                Case 8
                    ver = "97"
                Case Else
                    ver = "Dunno"
            End Select
        End If
        verstring = verstring &  strapp(appCount) & ": " & ver & vbcrlf
        app.Quit
    Next
wscript.echo verstring

Open in new window

0
 
Chris BottomleyCommented:
Sorry found a minor bug ... use the following instead if you want.

Chris
dim constApps 
Dim app
Dim strapp
dim appCount
dim ver
dim verstring
 
    constapps = "Access, Excel, Word, Powerpoint, Visio"
    strapp = Split(Replace(constApps, ", ", ","), ",")
    On Error Resume Next
    For appCount = 0 To UBound(strapp)
        set app = nothing
        Set app = CreateObject(strapp(appCount) & ".application")
        If app Is Nothing Then
            ver = " not found"
        Else
            Select Case CInt(app.Version)
                Case 12
                    ver = "2007"
                Case 11
                    ver = "2003"
                Case 10
                    ver = "XP .. 2002"
                Case 9
                    ver = "2000"
                Case 8
                    ver = "97"
                Case Else
                    ver = "Dunno"
            End Select
        End If
        verstring = verstring &  strapp(appCount) & ": " & ver & vbcrlf
        app.Quit
    Next
wscript.echo verstring

Open in new window

0
 
rolandkg1001Author Commented:
Wow! Looks great! Thanks.
But does this work in VBA? I think this is a script for visual basic and not for VBA, isn't it?
0
 
Chris BottomleyCommented:
As it is it is a stand alone script which will will run once pasted into a file and not need any application installed hence will be tolreant of any combination of applications.

i.e. it is a bit like a DOS batch fil but is windows OS specific.

Chris
0
 
Chris BottomleyCommented:
I you stillwant it to run in one of the MS office apps as a VBA routine then of course it can be easilyconverted.

Chris
0
 
Chris BottomleyCommented:
If it helps

Take the attached file and rename it as .vbs instead of .txt then double clickon it or selec run by whatever means suits you.

Chris
MS-Versions.txt
0
 
Chris BottomleyCommented:
And this is the same code structured as a VBA sub.

Chris
Sub msAppVers()
Dim constApps As String
Dim app As Object
Dim strapp() As String
Dim appCount As Integer
Dim ver As String
Dim verstring As String
 
    constApps = "Access, Excel, Word, Powerpoint, Visio"
    strapp = Split(Replace(constApps, ", ", ","), ",")
    On Error Resume Next
    For appCount = 0 To UBound(strapp)
        Set app = Nothing
        Set app = CreateObject(strapp(appCount) & ".application")
        If app Is Nothing Then
            ver = " not found"
        Else
            Select Case CInt(app.Version)
                Case 12
                    ver = "2007"
                Case 11
                    ver = "2003"
                Case 10
                    ver = "XP .. 2002"
                Case 9
                    ver = "2000"
                Case 8
                    ver = "97"
                Case Else
                    ver = "Dunno"
            End Select
        End If
        verstring = verstring & strapp(appCount) & ": " & ver & vbCrLf
        app.Quit
    Next
    Debug.Print verstring
    MsgBox verstring
End Sub

Open in new window

0
 
rolandkg1001Author Commented:
Hey, this is like Christmas!

Thanks  ;-))))))

I need a view days to check if this works for me. I am sure it does.
I need a few days, because I have only little time left in this week for doing my job on programming.
0
 
rolandkg1001Author Commented:
Hi Chris,

I quick tried your MSVersion.vbs script. The message box tells me for all versions "Dunno" even I have installed office 2003??
0
 
Shanmuga SundaramCommented:
Please re-check. It works fine. both in vba module and vbs script. I tried for you and see the attached screenshot
result.GIF
0
 
Chris BottomleyCommented:
I have used it on a number of systems since with no issues apparent.  Is there an issue relating to activation perhaps?

Chris
0
 
rolandkg1001Author Commented:
Sorry, no chance.

You can see my screenshots in the doc file attached. It is a registered doc version.
Test.doc
0
 
rolandkg1001Author Commented:
Maybe a help for finding the problem.

I have added the following line to your code:
wscript.echo CInt(app.Version)
Because I do not know the language I do not know if it should really show anything. Fact is, the msgbox is the same as in the screenshot. So maybe app.Version is Null or Nothing?
0
 
rolandkg1001Author Commented:
I have changed the code now to the attaced snippset. What the msgbox tells me, look at the screenshot.

Dim strapp
dim appCount
dim ver
dim verstring
Dim sversion 
 
    constapps = "Access, Excel, Word, Powerpoint, Visio"
    strapp = Split(Replace(constApps, ", ", ","), ",")
    On Error Resume Next
    For appCount = 0 To UBound(strapp)
        set app = nothing
      
	Set app = CreateObject(strapp(appCount) & ".application")
	
        If app Is Nothing Then
            ver = " not found"
        Else
            Select Case CInt(app.Version)
                Case 12
                    ver = "2007"
                Case 11
                    ver = "2003"
                Case 10
                    ver = "XP .. 2002"
                Case 9
                    ver = "2000"
                Case 8
                    ver = "97"
                Case Else
                    ver = "Dunno " & app.version
            End Select
        End If
        verstring = verstring &  strapp(appCount) & ": " & ver & vbcrlf
        app.Quit
    Next
wscript.echo verstring

Open in new window

msgbox.bmp
0
 
rolandkg1001Author Commented:
I have found out the problem by using your vba script. The cint(app.version) = 110, but in Select Case you are asking for 11. Do you know a good way to come around this bug in your code?

Debug.Print cint(app.Version)
 110

Debug.Print app.Version
11.0

0
 
Chris BottomleyCommented:
Ok

I've fiddled it and it works on my machine this way and hopefully will for you.

Be so kind as to replace your VBS file with the following and let me know how it goes.

Chris
dim constApps 
Dim app
Dim strapp
dim appCount
dim ver
dim verstring
 
    constapps = "Access, Excel, Word, Powerpoint, Visio"
    strapp = Split(Replace(constApps, ", ", ","), ",")
    On Error Resume Next
    For appCount = 0 To UBound(strapp)
        set app = nothing
        Set app = CreateObject(strapp(appCount) & ".application")
        If app Is Nothing Then
            ver = " not found"
        Else
            Select Case cint(left(app.Version & ".", instr(app.Version & ".", ".") - 1))
                Case 12
                    ver = "2007"
                Case 11
                    ver = "2003"
                Case 10
                    ver = "XP .. 2002"
                Case 9
                    ver = "2000"
                Case 8
                    ver = "97"
                Case Else
                    ver = "Dunno"
            End Select
        End If
        verstring = verstring &  strapp(appCount) & ": " & ver & vbcrlf
        app.Quit
    Next
wscript.echo verstring

Open in new window

0
 
rolandkg1001Author Commented:
Thanks to all!  

;-))
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 9
  • 8
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now