Results 1 to 7 of 7

Thread: how to know if the Msword has been install in the computer?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Location
    nanchang
    Posts
    17

    how to know if the Msword has been install in the computer?

    My program uses the msword ,tell me how to know if the Msword has been install in the computer.Thank you!

  2. #2
    Lively Member
    Join Date
    Nov 2001
    Location
    Lövéte, Hargita
    Posts
    66
    There is a module attached to this post. Try the IsMSWord function. Thsi is what you look for?

    Regards
    fazek

  3. #3
    Junior Member
    Join Date
    Oct 2001
    Posts
    21

    try to create the word.application object

    Hi There!

    Maybe you could try to late bind the Word.Application object:

    Code:
    Funtion bWordInstalled() As Boolean
    
       Dim oWordApp As Object
    
    On Error Resume Next
    
       Set oWordApp = CreateObject("Word.Application")
       bWordInstalled = IIf (Err.Number = 0, True, False)
    
    End Function

  4. #4
    Addicted Member aturner's Avatar
    Join Date
    Nov 2000
    Posts
    179
    why dont you just look for the winword.exe file, surely if it hasnt been installed the file wont be there ...
    Due to the energy crisis, the light at the end of the tunnel has been turned off.
    Sorry for any inconvenience this may cause

  5. #5
    VBShipWreck
    Guest
    you could also check the registry to see if the key HKEY_CLASSES_ROOT\Word.Application exists

  6. #6
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Here is some code that will return the office component and its current path. This is also from http://www.vb-world.net/
    VB Code:
    1. Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias _
    2.    "RegOpenKeyExA" (ByVal hKey As Long, _
    3.    ByVal lpSubKey As String, ByVal ulOptions As Long, _
    4.    ByVal samDesired As Long, phkResult As Long) _
    5.    As Long
    6.  
    7. Private Declare Function RegQueryValueEx Lib "advapi32.dll" _
    8.    Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal _
    9.    lpValueName As String, ByVal lpReserved As Long, _
    10.    lpType As Long, ByVal lpData As String, lpcbData As Long) _
    11.    As Long
    12.                                                                                                  
    13. Private Declare Function RegCloseKey Lib "advapi32.dll" _
    14.    (ByVal hKey As Long) As Long
    15.  
    16. Private Const REG_SZ As Long = 1
    17. Private Const KEY_ALL_ACCESS = &H3F
    18. Private Const HKEY_LOCAL_MACHINE = &H80000002
    19.  
    20.  
    21. '*****************************************************
    22. 'These functions return the path to the specified office
    23. 'application or a 0-length string if the application does not
    24. 'exist on the machine.  This is one good way to check whether a
    25. 'specific office application is present before trying to run
    26. 'automation code for that application
    27. '*****************************************************
    28. Public Function GetWordPath() As String
    29.     GetWordPath = GetOfficeAppPath("Word.Application")
    30.     'display path
    31.     MsgBox GetWordPath
    32. End Function
    33.  
    34. Public Function GetExcelPath() As String
    35.     GetExcelPath = GetOfficeAppPath("Excel.Application")
    36.     'display path
    37.     MsgBox GetExcelPath
    38. End Function
    39.  
    40. Public Function GetAccessPath() As String
    41.     GetAccessPath = GetOfficeAppPath("Access.Application")
    42.     'display path
    43.     MsgBox GetAccessPath
    44. End Function
    45.  
    46. Public Function GetOutlookPath() As String
    47.     GetOutlookPath = GetOfficeAppPath("Outlook.Application")
    48.      'display path
    49.     MsgBox GetOutlookPath
    50. End Function
    51.  
    52. Public Function GetPowerPointPath() As String
    53.     GetPowerPointPath =  GetOfficeAppPath("PowerPoint.Application")
    54.     'display path
    55.     MsgBox GetPowerPointPath
    56. End Function
    57.  
    58. Public Function GetFrontPagePath() As String
    59.     GetFrontPagePath = GetOfficeAppPath("FrontPage.Application")
    60.     'display path
    61.     MsgBox GetFrontPagePath
    62. End Function
    63.  
    64. Private Function GetOfficeAppPath(ByVal ProgID As String)  As String
    65.  
    66. Dim lKey As Long
    67. Dim lRet As Long
    68. Dim sClassID As String
    69. Dim sAns As String
    70. Dim lngBuffer As Long
    71. Dim lPos As Long
    72.  
    73.    'GetClassID
    74.    lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
    75.           "Software\Classes\" & ProgID & "\CLSID", 0&, _
    76.            KEY_ALL_ACCESS, lKey)
    77.    If lRet = 0 Then
    78.  
    79.       lRet = RegQueryValueEx(lKey, "", 0&, REG_SZ, "", lngBuffer)
    80.       sClassID = Space(lngBuffer)
    81.       lRet = RegQueryValueEx(lKey, "", 0&, REG_SZ, sClassID, _
    82.           lngBuffer)
    83.  
    84.       'drop null-terminator
    85.       sClassID = Left(sClassID, lngBuffer - 1)
    86.       RegCloseKey lKey
    87.    End If
    88.    
    89.    
    90.    'Get AppPath
    91.     lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _
    92.         "Software\Classes\CLSID\" & sClassID & _
    93.         "\LocalServer32", 0&, KEY_ALL_ACCESS, lKey)
    94.  
    95.   If lRet = 0 Then
    96.       lRet = RegQueryValueEx(lKey, "", 0&, REG_SZ, "", lngBuffer)
    97.       sAns = Space(lngBuffer)
    98.       lRet = RegQueryValueEx(lKey, "", 0&, REG_SZ, sAns, _
    99.         lngBuffer)
    100.       sAns = Left(sAns, lngBuffer - 1)
    101.      
    102.       RegCloseKey lKey
    103.    End If    
    104.    
    105.     'Sometimes the registry will return a switch
    106.        'beginning with "/" e.g., "/automation"
    107.    
    108.     lPos = InStr(sAns, "/")
    109.         If lPos > 0 Then
    110.             sAns = Trim(Left(sAns, lPos - 1))
    111.         End If
    112.    
    113.     GetOfficeAppPath = sAns
    114.    
    115. End Function

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