View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Simon Lloyd[_961_] Simon Lloyd[_961_] is offline
external usenet poster
 
Posts: 1
Default Determining if the user enabled macros


You will need to protect both the worksheet(s) and workbook structure
like this:

Code:
--------------------
ActiveWorkbook.Protect Password:="PASSWORD", Structu=True, Windows:=False
ActiveSheet.Protect Password:="PASSWORD", Contents:=True, Scenarios:=True
--------------------
Substitute PASSWORD for whatever password you wish, just amend the code
for UnProtect.JBeaucaire;167068 Wrote:
Create a Workbook_BeforeSave and a Workbook_Close macro that protects
the sheet completely from any changes.

Then put in a Workbook_Open macro to unprotect the sheet automatically.

Since the protection is occuring in the background, only clicking on
ENABLE MACROS will present the user with a sheet that can be edited
since the Workbook_Open event won't run and unprotect it without macros
being enabled.

Also, once you've done this, be sure to password protect the code in
the VBE, too, so they can't read the code without a password, perhaps
the same one you're protecting and unprotecting with in the background.



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=46287