Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Automatically close all Excel workbooks without saving
Message
 
À
12/01/2005 12:25:12
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00976227
Message ID:
00977045
Vues:
42
Hi Randy,

Thanks for your insight.
I will take that into consideration.

-- David

>I suppose you could use something like:
>
>FOR EACH oWB IN ExcelObj.Workbooks
> oWB.Close(.F.)
>ENDFOR
>
>*However* this isn't something I would choose lightly! How are you opening Excel in the first place? If you use GETOBJECT() you can grab a reference to an already-running version, which may have workbooks open that are not related to your purpose. Running the above code would close the user's work without saving!
>
>My suggestion is to maintain your own references, perhaps via a VFP collection, of the WBs that are "yours", and only close those.
>
>-- Randy
>
>
>>Thanks Randy! How could I iterate through all the workbooks to close them all without saving changes?
>>
>>>>How to automatically close all Excel opened workbooks without saving it?
>>>>
>>>>I would like to do this in the finally section in the try-catch block before quiting Excel so that it would get stuck with an "Do you want to save your workbook?" Dialog.
>>>>
>>>>Thanks!
>>>
>>>If you pass .F. as the first parameter of Close() as in Workbook.Close(.F.) you should avoid the dialog. Same is true for Word documents.
>>>
>>>-- Randy
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform