View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
sparx
 
Posts: n/a
Default Stop renaming or moving sheet tabs


Hello Bob, after several attempts of placing where to set the unprotect
password, ive managed to get my file working fine - I have vba with hide
and unhidesheets at workbook open and close - this is 2 of the codes I
use - kindly provided by others on this forum but have added some items
- you must note, I am nowhere near a vba expert so here goes.

Private Sub HideSheets()
Dim sht As Object
Application.ScreenUpdating = False
ActiveWorkbook.Unprotect Password:="Something Usefull"
ThisWorkbook.Sheets("Information").Visible = xlSheetVisible
For Each sht In ThisWorkbook.Sheets
If sht.name < "Information" Then sht.Visible = xlSheetVeryHidden
Next sht
Application.ScreenUpdating = True
Application.EnableEvents = False
ActiveWorkbook.Protect Password:="Something Usefull",
Structu=True, Windows:=False
ThisWorkbook.Save
Application.EnableEvents = True

End Sub

Private Sub UnhideSheets()
ActiveWorkbook.Unprotect Password:="Something Usefull"
Dim sht As Object
Application.ScreenUpdating = False
For Each sht In ThisWorkbook.Sheets
sht.Visible = xlSheetVisible
Next sht
ThisWorkbook.Sheets("Information").Visible = xlSheetVeryHidden
ActiveWorkbook.Protect Password:="Something Usefull",
Structu=True, Windows:=False
Application.ScreenUpdating = True

End Sub

The above code is within the "ThisWorkbook" page.

Its obviously doing something right - because I did get the message you
discussed but now dont and everything works perfectly - my saving, save
as and close - and when re-opening my file, if disable macro's is
selected, the workbook is still protected.

Hope you find some of this helpful.


--
sparx
------------------------------------------------------------------------
sparx's Profile: http://www.excelforum.com/member.php...o&userid=16787
View this thread: http://www.excelforum.com/showthread...hreadid=542084