View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Prevent user from Inserting new worksheet

I would be tempted to simply protect the workbook to prevent users from
inserting new sheets without running your macro.

In your macro unprotect, insert a sheet, then reprotect.

ActiveWorkbook.Unprotect Password:="justme"
'your insert hidden template sheet code here
ActiveWorkbook.Protect Password:="justme", Structu=True, Windows:=True

Second point.................

To ignore the warning when deleting sheets

application.displayalerts = false
ActiveWorkbook.Sheets(Sh.Name).Delete
application.displayalerts = true

But if you follow the first recommendation you won't need that.


Gord Dibben MS Excel MVP

On Tue, 23 Mar 2010 14:00:02 -0700, DocBrown
wrote:

What is the approach I could use to prevent the user from adding new blank
worksheets using the Insert.. Worksheet... function? I've found the
Workbook_NewSheet event but this fires after the sheet has been created.

I have a command button on the sheet that creates the new sheets for the
user by copying a hidden template sheet. This macro does not trigger the
NewSheet event.

In the Workbook_NewSheet event, I can call the delete method:

ActiveWorkbook.Sheets(Sh.Name).Delete

but this generates the "Data may exist in sheet(s)... Warning. How do I
supress this?
Thanks