View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Macro to prevent adding sheet in a workbook.

Just some added thoughts.


Rob's method could of course could be easily defeated through overt action
by the user to break the protection.

Jim's method (like any software based protection) could be inadvertently
defeated by setting security to high and the user would never know you cared
whether worksheets were added or not.

--
Regards,
Tom Ogilvy

"Jim Thomlinson" wrote in message
...
Generally I agree with Rob that the best solution is probably to protect
the
workbook. If however you want to proceed this code will prevent new sheets
from being added. It does not however stop someone from copying sheets
into
the book.

This code goes in the ThisWorkbook module. Right clickt the Excel icon
next
to File on the menu and select view code. Add this code...

Private Sub Workbook_NewSheet(ByVal Sh As Object)
Application.DisplayAlerts = False
MsgBox "Sorry. No adding new sheets."
Sh.Delete
Application.DisplayAlerts = True
End Sub
--
HTH...

Jim Thomlinson


" wrote:

I need some help with writing a macro which can prevent th euser to add
additional sheets in a workbook.

thanks