• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User


  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to run macro at workbook open event without enabling content and also hide sheets without saving before close?


New Member
I am trying to protect a workbook using a macro. The macro activates the Userform which asks the user to put in the password. As soon as the user puts in the password, the hidden sheets of the workbook gets visible. I have written this macro in "This workbook" using Sub Workbook_open and Workbook_Close.

I am facing the following 2 issues currently:
1) The userform gets activated only after pressing "Enable content". Is there a way through which one can activate the userform without pressing the "Enable Content"? I don't want to manually change the "Trust Center" settings.
2) The macro needs to save the workbook before closing so that the sheets get hidden. I don't want to save the workbook before closing and still hide the all sheets except one sheet. Is there a way for this?

Thank you!