Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to know if MS-Word 2000 or better is available
Message
From
20/09/2006 05:11:29
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01155374
Message ID:
01155404
Views:
34
Yes, but if you need to load the application anyway, if installed, my approach adds zero time to the process. Your solution adds a little overhead which is really redundant.

>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
>>>
Previous
Reply
Map
View

Click here to load this message in the networking platform