Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to know if MS-Word 2000 or better is available
Message
De
20/09/2006 05:00:04
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01155374
Message ID:
01155400
Vues:
23
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
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform