[RESOLVED] Want to know installed MS Office edition using VB6
Hello,
I am in need of checking the MS Office edition installed on the user system. How can I check that?
Basically the problem is that, in case of Office is other than English Edition then I want to stop the user from login to the application, as my application generates some word documents and in case of Office being other than English edition the application crashes.
Thx for your time.
Re: Want to know installed MS Office edition using VB6
Sanju, Have you tried in Registry. I hope you can find the version details in the Registry of MS Office
Re: Want to know installed MS Office edition using VB6
Here is an easy way to do it
VB Code:
Dim testApp As Object
'Version of word
Set testApp = CreateObject("Word.Application")
MsgBox testApp.version
'Version of excel
Set testApp = CreateObject("Excel.Application")
MsgBox testApp.version
'Version of access
Set testApp = CreateObject("Access.Application")
MsgBox testApp.version
'Version of outlook
Set testApp = CreateObject("Outlook.Application")
MsgBox testApp.version
'Version of Powerpoint
Set testApp = CreateObject("Powerpoint.Application")
MsgBox testApp.version
'Version of Visio
Set testApp = CreateObject("Visio.Application")
MsgBox testApp.version
Set testApp = Nothing
I don't know of any API's that can help you get the version of office applications installed on the system.
Edit--
IF any of the applications is not installed on the system, the CreateObject will raise "ActiveX Component Can't create Object Error". So you will have to handle that error.
Re: Want to know installed MS Office edition using VB6
Hi Shuja,
Thanks for your answer but my requirement is bit different here. I dont want to know the version, but i want to check what edition of ms office is installed like MS Office comes in US English edition, Japanese Edition, French Edition etc..
Like many of my users are in France, so they generally have MS Office French edition.
So i want to check this thing.
Re: Want to know installed MS Office edition using VB6
Hi,
Add this code to Shuja's code:
VB Code:
If testApp.Language = msoLanguageIDEnglishUS Then
MsgBox "The user interface language is U.S. English."
Else
MsgBox "The user interface language is not U.S. English."
End If
The above code is not tested. let us know if the problem is not solved.
Re: Want to know installed MS Office edition using VB6
No it does not. It is giving error as object type not supported.
Re: Want to know installed MS Office edition using VB6
This works perfectly..
VB Code:
Dim testApp As Object
'Version of word
Set testApp = CreateObject("Word.Application")
If testApp.Language = msoLanguageIDFrench Then
MsgBox "French Edition Installed"
Else
'some other edition
End If
Re: Want to know installed MS Office edition using VB6
Set reference to Microsoft Word object for Word application.
Re: Want to know installed MS Office edition using VB6
Quote:
Originally Posted by cssriraman
Set reference to Microsoft Word object for Word application.
There is no need to set the reference, the above code uses Late Binding.
Re: Want to know installed MS Office edition using VB6
msoLanguageIDFrench or msoLanguageIDEnglish have no value in them. they are showing empty value. so how to get value in that?
Re: Want to know installed MS Office edition using VB6
VB Code:
Option Explicit
Const msoLanguageIDEnglishUS = 1033
Sub Main()
Dim WdApp As Object
Set WdApp = CreateObject("Word.Application")
If WdApp.Language = msoLanguageIDEnglishUS Then
MsgBox "The user interface language is U.S. English."
Else
MsgBox "The user interface language is not U.S. English."
End If
Set WdApp = Nothing
End Sub
Re: Want to know installed MS Office edition using VB6
Re: Want to know installed MS Office edition using VB6
Just do
VB Code:
Dim objLangId As Object
Dim lngId As Long
Set objLangId = CreateObject("Word.Application")
lngId = objLangId.Language
Msgbox lngId
Refer to this link under MsoLanguageId to get a listing of every language that it is possible to get MS Office under.
Re: [RESOLVED] Want to know installed MS Office edition using VB6
Hi Hack,
Thanks for the link. But now Again I am in doubt that I will allow the user to enter in my application if the language is English(It may be US or UK or anything else but Only english.) so how will i check that? Thanks for lal your help.
Re: [RESOLVED] Want to know installed MS Office edition using VB6
Use the Language Ids
VB Code:
Dim objLangId As Object
Dim lngId As Long
Set objLangId = CreateObject("Word.Application")
lngId = objLangId.Language
Select Case lngId
Case 1033, 2057 'US and UK English
'do whatever if it is English
Case Else
'do whatever if it is not English
End Select
Re: [RESOLVED] Want to know installed MS Office edition using VB6
So it means I have to write all the following codes where English is coming,
msoLanguageIDEnglishAUS 3081
msoLanguageIDEnglishBelize 10249
msoLanguageIDEnglishCanadian 4105
msoLanguageIDEnglishCaribbean 9225
msoLanguageIDEnglishIndonesia 14345
msoLanguageIDEnglishIreland 6153
msoLanguageIDEnglishJamaica 8201
msoLanguageIDEnglishNewZealand 5129
msoLanguageIDEnglishPhilippines 13321
msoLanguageIDEnglishSouthAfrica 7177
msoLanguageIDEnglishTrinidad 11273
msoLanguageIDEnglishTrinidadTobago 11273
msoLanguageIDEnglishUK 2057
msoLanguageIDEnglishUS 1033
msoLanguageIDEnglishZimbabwe 12297
Can't I just check keyword English?
Re: [RESOLVED] Want to know installed MS Office edition using VB6
Quote:
Originally Posted by sanbatra
So it means I have to write all the following codes where English is coming,
msoLanguageIDEnglishAUS 3081
msoLanguageIDEnglishBelize 10249
msoLanguageIDEnglishCanadian 4105
msoLanguageIDEnglishCaribbean 9225
msoLanguageIDEnglishIndonesia 14345
msoLanguageIDEnglishIreland 6153
msoLanguageIDEnglishJamaica 8201
msoLanguageIDEnglishNewZealand 5129
msoLanguageIDEnglishPhilippines 13321
msoLanguageIDEnglishSouthAfrica 7177
msoLanguageIDEnglishTrinidad 11273
msoLanguageIDEnglishTrinidadTobago 11273
msoLanguageIDEnglishUK 2057
msoLanguageIDEnglishUS 1033
msoLanguageIDEnglishZimbabwe 12297
Can't I just check keyword English?
It is one line of code and I've written it for you.
VB Code:
Dim objLangId As Object
Dim lngId As Long
Set objLangId = CreateObject("Word.Application")
lngId = objLangId.Language
Select Case lngId
Case 1033, 2057, 3081, 10249, 4105, 9225, 14345, 6153, 8201, 5129, 13321, 7177, 11273, 12297
'do whatever if it is English
Case Else
'do whatever if it is not English
End Select
Re: [RESOLVED] Want to know installed MS Office edition using VB6
Thanks for your cooperation Hack, but my intention was not that I have to write so many codes, but I was just thinking of a way to get English. Maybe I am expecting too much .. but neways thanks a lot for your help.
Re: [RESOLVED] Want to know installed MS Office edition using VB6
Quote:
Originally Posted by sanbatra
Thanks for your cooperation Hack, but my intention was not that I have to write so many codes, but I was just thinking of a way to get English. Maybe I am expecting too much .. but neways thanks a lot for your help.
I can't think of any easier way, and the code to retrieve the language edition is not that long or complicated, so this should do the trick for you.
If not, let us know, and we will see what else we can come up with. :)