Don't save before close event?

D

Don Wiss

I'm working on an add-in that will have a user form. I'd like the form to
save its input between shows of it. Apparently the only way to save the
input is in cells on a spreadsheet. That's okay, but I don't want the user
to be asked if they want to save when closing the add-in. What event do I
call so that it exits without asking to save?

Don <donwiss at panix.com>.
 
B

Bob Kilmer

Setting the Saved property of the Workbook to True tells Excel there are in
effect no changes and no need to save the workbook. The prompt will not
appear if you set this to true. (ThisWorkbook.Saved = True) Perhaps it goes
without saying, but I'll say it anyway: You should not carelessly cause a
user's work to be discarded, which could happen if you set this property to
True, but do not save the workbook yourself.

Workbook_BeforeClose event is an event that is raised, as it says, before
closing. You can do clean up in response to this event.

Alternatively, you could save your form data in the registry (using
SaveSetting, GetSetting) or in a file (using something like Open
Environ("APPDATA") & "\MyApp\Settings.csv" for Output as #1: Print #1, data:
Close #1).

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top