Results 1 to 19 of 19

Thread: [RESOLVED] Want to know installed MS Office edition using VB6

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    India
    Posts
    84

    Resolved [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.

  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    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
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  3. #3
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Want to know installed MS Office edition using VB6

    Here is an easy way to do it
    VB Code:
    1. Dim testApp As Object
    2.     'Version of word
    3.     Set testApp = CreateObject("Word.Application")
    4.     MsgBox testApp.version
    5.     'Version of excel
    6.     Set testApp = CreateObject("Excel.Application")
    7.     MsgBox testApp.version
    8.     'Version of access
    9.     Set testApp = CreateObject("Access.Application")
    10.     MsgBox testApp.version
    11.     'Version of outlook
    12.     Set testApp = CreateObject("Outlook.Application")
    13.     MsgBox testApp.version
    14.     'Version of Powerpoint
    15.     Set testApp = CreateObject("Powerpoint.Application")
    16.     MsgBox testApp.version
    17.     'Version of Visio
    18.     Set testApp = CreateObject("Visio.Application")
    19.     MsgBox testApp.version
    20.    
    21.     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.
    Last edited by Shuja Ali; Jun 15th, 2006 at 05:29 AM.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    India
    Posts
    84

    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.

  5. #5
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Want to know installed MS Office edition using VB6

    Hi,

    Add this code to Shuja's code:
    VB Code:
    1. If testApp.Language = msoLanguageIDEnglishUS Then
    2.         MsgBox "The user interface language is U.S. English."
    3. Else
    4.         MsgBox "The user interface language is not U.S. English."
    5. End If
    The above code is not tested. let us know if the problem is not solved.
    CS

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    India
    Posts
    84

    Re: Want to know installed MS Office edition using VB6

    No it does not. It is giving error as object type not supported.

  7. #7
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Want to know installed MS Office edition using VB6

    This works perfectly..
    VB Code:
    1. Dim testApp As Object
    2.     'Version of word
    3.     Set testApp = CreateObject("Word.Application")
    4.     If testApp.Language = msoLanguageIDFrench Then
    5.         MsgBox "French Edition Installed"
    6.     Else
    7.         'some other edition
    8.     End If
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  8. #8
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Want to know installed MS Office edition using VB6

    Set reference to Microsoft Word object for Word application.
    CS

  9. #9
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    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.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    India
    Posts
    84

    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?

  11. #11
    Frenzied Member cssriraman's Avatar
    Join Date
    Jun 2005
    Posts
    1,465

    Re: Want to know installed MS Office edition using VB6

    VB Code:
    1. Option Explicit
    2.  
    3. Const msoLanguageIDEnglishUS = 1033
    4.  
    5. Sub Main()
    6.     Dim WdApp As Object
    7.     Set WdApp = CreateObject("Word.Application")
    8.  
    9.     If WdApp.Language = msoLanguageIDEnglishUS Then
    10.         MsgBox "The user interface language is U.S. English."
    11.     Else
    12.         MsgBox "The user interface language is not U.S. English."
    13.     End If
    14.     Set WdApp = Nothing
    15. End Sub
    CS

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    India
    Posts
    84

    Re: Want to know installed MS Office edition using VB6

    Thanks it works.

  13. #13
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Want to know installed MS Office edition using VB6

    Just do
    VB Code:
    1. Dim objLangId As Object
    2. Dim lngId As Long
    3. Set objLangId = CreateObject("Word.Application")
    4. lngId = objLangId.Language
    5. Msgbox lngId
    Refer to this link under MsoLanguageId to get a listing of every language that it is possible to get MS Office under.

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    India
    Posts
    84

    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.

  15. #15
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [RESOLVED] Want to know installed MS Office edition using VB6

    Use the Language Ids
    VB Code:
    1. Dim objLangId As Object
    2. Dim lngId As Long
    3. Set objLangId = CreateObject("Word.Application")
    4. lngId = objLangId.Language
    5. Select Case lngId
    6.     Case 1033, 2057 'US and UK English
    7.         'do whatever if it is English
    8.     Case Else  
    9.         'do whatever if it is not English
    10. End Select

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    India
    Posts
    84

    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?

  17. #17
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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:
    1. Dim objLangId As Object
    2. Dim lngId As Long
    3. Set objLangId = CreateObject("Word.Application")
    4. lngId = objLangId.Language
    5. Select Case lngId
    6.     Case 1033, 2057, 3081, 10249, 4105, 9225, 14345, 6153, 8201, 5129, 13321, 7177, 11273, 12297
    7.         'do whatever if it is English
    8.     Case Else  
    9.         'do whatever if it is not English
    10. End Select

  18. #18

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    India
    Posts
    84

    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.

  19. #19
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width