SaveAs closing file without firing event WorkBook_beforeclose

P

PFS

Hi,

I have a workbook which very-hides all of the sheets but one in the
BeforeSave and BeforeClose events.

So that if a user opens up the workbook without macros enabled all they
will see is the front page, nothing else. If they open it with macros
enabled and their password has been entered, it opens the rest of the
sheets. Got that working beautifully if you use Close or Save or even
in SaveAs in the newly created file.

I have found a loophole though, which I will try to explain.

When you have the original file (I will call this file A) and open it
up with macros enabled, enter a password, get into it and then, do a
"Save As" to File B.

Now I don't really understand what is happening but as Excel does the
"Save As", it goes through a process to close File A which doesn't seem
to invoke the WorkBook_BeforeClose event (which hides everything
again). So now we have File B open, and File A closed (by the SaveAs
command).

Consequently, you can close File B and then open File A, disable
macros, and then gain access to the whole spreadsheet because it hasn't
gone through a "normal" close procedure.

Any ideas on how to close this loophole

cheers

Paul
 

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