rolandkg1001
asked on
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!!!
does anybody have a VBA code snippet for me, which tells me, which version of word and excel the user has installed?
Thanks!!!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
Sorry found a minor bug ... use the following instead if you want.
Chris
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
ASKER
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?
But does this work in VBA? I think this is a script for visual basic and not for VBA, isn't it?
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
i.e. it is a bit like a DOS batch fil but is windows OS specific.
Chris
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
Chris
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
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
And this is the same code structured as a VBA sub.
Chris
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
ASKER
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.
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.
ASKER
Hi Chris,
I quick tried your MSVersion.vbs script. The message box tells me for all versions "Dunno" even I have installed office 2003??
I quick tried your MSVersion.vbs script. The message box tells me for all versions "Dunno" even I have installed office 2003??
Please re-check. It works fine. both in vba module and vbs script. I tried for you and see the attached screenshot
result.GIF
result.GIF
I have used it on a number of systems since with no issues apparent. Is there an issue relating to activation perhaps?
Chris
Chris
ASKER
Sorry, no chance.
You can see my screenshots in the doc file attached. It is a registered doc version.
Test.doc
You can see my screenshots in the doc file attached. It is a registered doc version.
Test.doc
ASKER
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?
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?
ASKER
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
msgbox.bmp
ASKER
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
Debug.Print cint(app.Version)
110
Debug.Print app.Version
11.0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to all!
;-))
;-))
ASKER
I try your solutions....