moon said:
Be inventive, let the workbook come up with an empty sheet by default and
show the real stuff if macro's is enabled.
Pretty good idea. At first I thought that you could defeat it by
disabling macros *after* the workbook is open (so that the before_close
or auto_close macros which presumably rehide the sheets wouldn't fire)
but discovered that disabling macros while a workbook is open only
takes effect after the workbook is closed. Then I thought of typing
"Application.EnableEvents = False" in the immediate window. That *will*
disable the before_close event but not the auto_close macro. Finally, I
wrote a script:
'MakeVisible.vbs
Option Explicit
Dim xlApp, wb, ws
Set xlApp = CreateObject("Excel.Application")
xlApp.EnableEvents = False
Set wb = xlapp.Workbooks.Open("trial.xls")
For Each ws in wb.Worksheets
ws.Visible = -1 'xlSheetVisible
Next
wb.Save
wb.Close
Set wb = Nothing
Set xlapp = Nothing
This seems to make all sheets visible without running any macros, but
maybe I'm missing something.
A non-programmer wouln't have the requisite know-how, but it caught my
interest when in your earlier post (which, by the way, contained some
nice code) you warned about sophisticated users who might know how to
edit registry keys. I wondered how such users could thwart the VBA and
how the VBA programmer could in turn thwart them.
An idea I had in an earlier thread (concerning copy-protection) is to
make VBA functionally essential (if it isn't already) by replacing
spreadsheet formulas by user-defined functions which duplicate their
functionality. In many cases this could be achieved by dummy functions
which call the corresponding Application.WorksheetFunction or use
Evaluate on the string representing the original function (with
appropriate substitutions). This would entail some programming overhead
- but you only have to do it on a handful of crucial formulas to
disable the spreadsheet (there better be some pretty special formulas
to justify charging money for the file). The user-defined functions
might entail some overhead, so the macro to be run upon registration
could replace them by the corresponding worksheet functions.
It all depends on how paranoid you want (or need) to be.
-John Coleman