Workbook_Beforeclose vs BeforeClose Event

J

jasonsweeney

I am trying to run some code rightbefore a workbook closes. The code
relates to resetting some passwords hidden in a worksheet.

What I want is the code to execute after a person tries to close the
workbook.

Right now I am using the "BeforeClose" event. The problem here is that
the code executes, and then Excel asks the user whether they want to
save changes made to the worksheet before closing. If the person says
no, then my the effect of my password codes does not take effect.

I want to use the Workbook_BeforeClose event, which I think is the last
event before the workbook closes, which would allow me to get my
desired effect without allowing the user to "veto" the cnages I make to
their worksheet right before it closes.

However, nothing happens when I use the event. I think this is because
I have to "create a new class module and declare an object of type
Application with events." (VBA Help for WorkbookBeforeClose Event". I
have noever done this before.

Any suggestions?
 

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