Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to know if MS-Word 2000 or better is available
Message
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:
01155394
Vues:
21
This message has been marked as a message which has helped to the initial question of the thread.
>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform