Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need Command/Call to Kill Running Excel Instance
Message
De
21/04/2010 18:13:55
Bill Drew
Independent Consultant
Chicago, Illinois, États-Unis
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01461076
Message ID:
01461411
Vues:
51
>Did you try using the GETOBJECT() function?

I wondered if there might be a way to do it with not API call. I like it.

>
>
>LOCAL oleApp AS "Excel.Application"
>
>TRY 
>	oleApp = GETOBJECT(, "Excel.Application")
>	
>	IF oleApp.Visible = .T.
>		* do not close any visible instances of ms excel.
>	ELSE
>		oleApp.Quit()
>	ENDIF
>
>CATCH
>	* ignore any errors.
>	
>FINALLY
>	STORE .NULL. TO oleApp
>	
>ENDTRY
>
>
>
>>I do a lot of Excel automation. So much that I have a standard stack of commands that I use over and over. oExcel = CreateObject("Excel Application") etc etc. Make an oBook object. Make an OSheet object. Get number of used rows. Iterate through the rows. Do something with the data. Close the Book. Quit Excel. and set the oExcel object to NULL.
>>
>>As I am writing the programs I invariably have bugs somewhere in the process. In those cases where the program never makes it to the final lines of setting the oExcel object to NULL, I have to go to the task manager to kill the instance before restarting.
>>
>>Is there an API call or command that I can use at the beginning of my programs to check for a running instance of Excel and to shut it down before starting a new one. Or (just thinking of another way) should I put the code into a try catch construct? The disadvantage of Try Catch is that interactive debugging is hobbled.
>>
>>Thanks.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform