Prevent user from disabling macros

  • Thread starter Thread starter Michael Monteiro
  • Start date Start date
M

Michael Monteiro

I know you cannot prevent user's from disabling macros,
but it seems you can prevent users from using a
spreadsheet as it was intended if they do not enable them.
I understand that Excel 4.0 macros cannot be disabled, so
here is my thought.

Write an Exel 4.0 marco to hide all sheets in the workbook
(I am assuming that this can be done and that the user
cannot unhide them once they've been hidden
programmatically). Then, in the Workbook_Open event, show
all the worksheets. If they elect not to enable macros,
they will not see any sheets. Does this seem like the best
way to make users enable macros? If so, how do I write
this hide macro in Excel 4.0? Is there a better way?

TIA for your help.

Michael
 
John Wilson said:
Michael,

Why an Excel 4.0 Macro????

Attached below is some code from a previous post of mine.
Should get you started.

<snip>
The only way to do this is to hide all the sheets except one when
the workbook is saved (making the workbook unusable).
On that one unhidden sheet, you'll need to place some text alerting
the user that they need to enable macros and instruction on how
to do so. You'll also need to protect the VBA project so they can't
easily get at the underlying code. Please be aware though that an
experienced user can crack any VBA code that you have or make
the sheets that you've hidden, visible again even without getting
into your VBA code.

Having said that, here's some code that will attempt to do what
you want. Try this in a brandy new workbook first to see how
it works and then adapt the code to fit your needs (based on how
your sheets are laid out)

How it works:
On Close, nothing happens (except the close) because the
stored copy already has all but sheet(1) hidden.
If the user saves the workbook...
His/her last active cell address is saved in a memvar


Whoa right there... Just what is a memvar?

Would someone be so kind as to elaborate? Could it be that there is some
sort of non-volatile memory capability for simple variables? Please, Please
let it be true.

--
Terry

"I said I never had much use for one,
I never said I didn't know how to use one."
M. Quigley
 
Terry,
Whoa right there... Just what is a memvar?
Maybe a poor choice of words on my part.
By "memvar" I was referring to a "Memory Variable".
I'm not sure where I got the term from (Lotus, FoxPro, whatever)
but it's nothing more than a Variable.
Could it be that there is some sort of non-volatile memory capability
for simple variables? Please, Please let it be true.
Well........yes and no.
There isn't a non-volatile memory capability but there are other ways
around it. You could save the variable to an obscure cell in the workbook,
you could store it to the registry or store the variable in a named range
that doesn't reference a cell. John Walkenback has an example on
his site somewhere but I can't seem to find it. It's probably similar
to the example given by Robert Rosenberg in this thread:
http://makeashorterlink.com/?K10D249A5

John
 
Patrick,

You really need to call the HideSheets sub in the Workbook
Before_Save event otherwise once the user has it open
(and visible), they need only save and reopen with macros
disabled and all sheets will be visible.

John
 
Back
Top