Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I check to see if Word exists?

Status
Not open for further replies.

Fion

Vendor
Sep 25, 2003
50
US
Hi, I am making a program that uses word for some functions, and I would like to be able to put some code in that will check to see if word is installed, so I can then enable the extra functions. Does anyone know a good way to do this? Ideally one that would work across multipule platforms (Xp and 2000, and possibly 98)..
Thanks for your help!
 
You can check for the existence of

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe

If it ain't there, neither's Word.

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"A computer program does what you tell it to do, not what you want it to do." -- Greer's Third Law
 
What is the best command to use to check if that exists? I really don't know enough about the API commands...
Thanks for your help!
 
Here is the code which checks the existence of the aforementioned key. The API code is wrapped in a function which returns True if word exists and False otherwise.
___
[tt]
Option Explicit
Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegQueryValue Lib "advapi32" Alias "RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long

Function DoesWordExist() As Boolean
Dim hKey As Long, RetVal As Long
Const HKEY_LOCAL_MACHINE = &H80000002
Const KEY_QUERY_VALUE = &H1
Const ERROR_SUCCESS = 0&
RetVal = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Winword.exe", 0, KEY_QUERY_VALUE, hKey)
RegCloseKey hKey
DoesWordExist = RetVal = ERROR_SUCCESS
End Function

Private Sub Form_Load()
MsgBox DoesWordExist
Unload Me
End Sub
[/tt]
 
Thanks alot! That works perfectly!
 
You can also just try to create the word object - if it fails then no version of exists on the pc.
[flowerface]

I was standing in the park, wondering why frisbees got bigger as they came closer... then it hit me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top