Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel installed
Message
From
09/09/2008 13:12:01
 
 
To
09/09/2008 13:02:00
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01345964
Message ID:
01346117
Views:
8
>>To work with Excel, I have this line:
>>
>>oExcel = CreateObject("Excel.Application")
>>
>>When running on a PC without Excel, got this error:-
>> "Class definition EXCEL.APPLICATION is not found."
>>
>>What is the best way to avoid this error?
>>
>>Cyril
>Here is the code I use.
>
>if ! IsClassRegistered("Excel.Application")
>	messagebox("Excel cannot be found on this PC. You must have Excel installed " + ;
>	"to run this procedure." + chr(10) +  "For further assistance please contact your software vendor.",16,"Error message")
>	return
>endif
>
>
>function IsClassRegistered
>	lparameters tcClass
>	#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
>
>	local lnKey
>	lnKey = 0
>	llRetVal = ( RegOpenKey(HKEY_CLASSES_ROOT, tcClass, @lnKey) = ERROR_SUCCESS )
>	if llRetVal
>		RegCloseKey(lnKey)
>	endif
>	return llRetVal
>endfunc
>
I still think my Try-Catch-Endtry routine is much simpler. :-)
Previous
Reply
Map
View

Click here to load this message in the networking platform