![]() ATOUTFOX COMMUNAUTÉ FRANCOPHONE DES PROFESSIONNELS FOXPRO Visual FoxPro : le développement durable |
|||||||||||||
|
|||||||||||||
Tester si Excel est lancé
|
|||||||||||||
|
|||||||||||||
www.atoutfox.org - Site de la Communauté Francophone des Professionnels FoxPro - v3.4.0 - © 2004-2023. |
Si on est sous VFP9, il y a une excellente alternative à ON ERROR : TRY.
En effet, dans cet exemple, il faudrait commencer par mémoriser l'éventuelle commande initiale de ON ERROR, puis remettre cette commande à la fin de la fonction.
Il y a beaucoup plus simple : TRY ... CATCH ... ENDTRY
ATTENTION : je ne sais pas ce que je fais comme bétise, mais malgré les espaces mis, j'ai un problème avec l'indentation !
FUNCTION Excel
LOCAL ok, loExcel
TRY
loExcel = GETOBJECT(, "Excel.Application")
ok = .F.
CATCH
ok = .T.
ENDTRY
IF !m.ok
TRY.
loExcel = createobject('excel.application')
ok=.t
CATCH
ok = .F.
ENDTRY
ENDIF
RETURN m.ok