Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to know if MS-Word 2000 or better is available
Message
 
To
20/09/2006 05:00:04
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01155374
Message ID:
01155401
Views:
22
Because I didn't care about the application version, I prefer to use this function, becuase it is faster, sometimes CREATEOBJECT() takes a some time until the application is loaded.



>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 && OK
>>
>>   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
>>
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform