Personally I prefer to use a try-catch block. If the application is installed, the try succeeds, the object is created and the program can proceed. If not the object is not created and I give a warning.
>>Hi all
>>
>>When a CREATEOBJECT() is executed to automate MS-Word it raises and error. How can I check before hand if MS-Word (better if I can find out if the version is 2000 or above) exists at all. I would like to disable a menu option before hand based on this fact.
>>
>>Please advise.
>
>I use this function to get if some class is registered. Unfortunately I can't remeber from whom I borrow it.
>(So if somebody recognise His/Her code, please let me know to put a comment)
>
>
>FUNCTION _IsClassRegistered(tcClass)
>
> LOCAL lnKey
> #define HKEY_CLASSES_ROOT -2147483648
> #define ERROR_SUCCESS 0
>
> DECLARE INTEGER RegOpenKey IN Win32API ;
> INTEGER nHKey, STRING @cSubKey, INTEGER @nResult
>
> DECLARE INTEGER RegCloseKey IN Win32API ;
> INTEGER nHKey
>
> lnKey = 0
> llRetVal = (RegOpenKey(HKEY_CLASSES_ROOT, tcClass, @lnKey) = ERROR_SUCCESS)
>
> IF llRetVal
> RegCloseKey(lnKey)
> ENDIF
>
>RETURN llRetVal
>
>
>
>You could use it:
>
>IF _IsClassRegistered([Word.Application])
> LOCAL oWord AS Word.Application
> LOCAL lcWordVersion
> *** Get Word version
> oWord = CREATEOBJECT([Word.Application])
> lcWordVersion = oWord.Version
> oWord.Quit()
> oWord = NULL
>ENDIF
>