Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is Word/Excel installed
Message
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00566415
Message ID:
00566767
Views:
25
>>>Is there a easy way to see if Word/Excel are installed on my system ?
>>>If i try a createobject("word.application") i get a CLASS DEFINITION IS NOT FOUND, but i want to check before i do the createobject.
>>
>>Yes, this can be done. Here's some code. Pass the server name, as in:
>>
>>lWordExists = CheckServer("Word.Application")
>>
>>Hope this helps,
>>
>> - della
>>
>>
* CheckServer.PRG
>>* Published in _Microsoft Office Automation with Visual FoxPro_,
>>* Hentzenwerke Publishing, June, 2000.
>>* www.hentzenwerke.com
>>* Copyright 2000 by Tamar E. Granor and Della Martin All Rights Reserved
>>
>>LPARAMETER cServerName
>>LOCAL oRegistry, cClassID, cEXEName, lEXEExists, ;
>>      aClassIDValues, aClassIDValues, aServerNameValues
>>
>>IF VERSION() >= "Visual FoxPro 06"
>>   oRegistry = NewObject("Registry", HOME() + "FFC\Registry")
>>ELSE
>>  SET PROCEDURE TO HOME() + "samples\classes\registry.prg" ADDITIVE
>>  oRegistry = CreateObject("Registry")
>>ENDIF
>>
>>lEXEExists = .F.
>>
>>DECLARE aClassIDValues[1], aServerNameValues[1]
>>
>>WITH oRegistry
>>  * Find the CLSID of the server. First, look for
>>  * the Class's Key.
>>  IF .OpenKey(cServerName + "\CLSID") = 0
>>    * The Class's Key is open, now enumerate its values
>>    .EnumKeyValues(@aClassIDValues)
>>
>>    * The data portion of the first (only) value returned
>>    * is the CLSID. Find the LocalServer32 key for the CLSID
>>    IF .OpenKey("CLSID\" + aClassIDValues[1,2] + "\LocalServer32") = 0
>>      * Enumerate the LocalServer32 values
>>      .EnumKeyValues(@aServerNameValues)
>>
>>      * The EXE file is stored in the first (only) data value returned.
>>      cEXEName = aServerNameValues[2]
>>
>>      * The value that's returned may have " -Automation" or " /Automation" or
>>      * " /AUTOMATION" & other trailing stuff at the end. Strip it off.
>>      IF "AUTO" $ UPPER(cEXEName)
>>        cEXEName = LEFT(cEXEName, ATC("AUTO", UPPER(cEXEName)) - 2)
>>      ENDIF
>>
>>      * Verify that the file exists
>>      lEXEExists = FILE(cEXEName)
>>    ENDIF
>>  ENDIF
>>ENDWITH
>>
>>RETURN lEXEExists
>
>This program expects the full version of VFP (with samples) to be installed on the machine, which checks for Word, right? It would not work with only run-time installation, would it?

Sure it'll. Just include Registry FFC class (VFP 7) or registry.prg for earlier versions in your project. If you have your own registry class than you can rewrite code to use it.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform