Hide sheets before macros can run

  • Thread starter Thread starter Rich
  • Start date Start date
R

Rich

My project is to secure an excel workbook for distribution to remote
agencies.
I have worked out a code for date checking, and how to close excel if
dates are reached.

I could say the project is finished at this stage, having reached my
objective but like others I can't in good conscience regard this as
'finished'. Purely because there are countless other security holes
which could be patched with macros if I could ject figure them out.

many ppl talk about forcing macros. I know now they can't literally be
forced, but we can persuade the user to use them.

Can someone please explain to me through the use of code, how to set a
dummy sheet (which I will have a message on, telling ppl to use
macros) while other sheets are hidden? And all this BEFORE macros are
given the chance to run??

Code for individually hiding sheets is relatively easy, but these are
macros. How are sheets hidden before macros are run?
 
Hi Rich

distribute the workbook with the sheets hidden and place before close code
to ensure that the sheets are are hidden again if the person enables macros,
opens the workbook and then closes it.

Cheers
JulieD
 
Hi
not tested but as a starting point.
1. Create your 'dummy sheet'

2.Put the following code in your workbook module (not in a standard module):
sub workbook_open()
dim wks as worksheet
application.screenupdating=false
with me
..unprotect password:="your_password"
for each wks in .worksheets
if lcase(wks.name)<>"dummy" then
..visible=true
end if
next wks
..worksheets("dummy").visible=xlsheetveryhidden
end with
application.screenupdating=true
end sub

sub workbook_beforeclose()
dim wks as worksheet
application.screenupdating=false
with me
..worksheets("dummy").visible=true
for each wks in .worksheets
if lcase(wks.name)<>"dummy" then
..visible=xlsheetveryhidden
end if
next wks
..protect password:="your_password"
..save
end with
application.screenupdating=true
end sub
 

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

Back
Top