Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel installed
Message
De
09/09/2008 13:02:00
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01345964
Message ID:
01346115
Vues:
9
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform