![]() |
how to protect header & footer
Can somebody tell me how I can protect the contents of Header & Footer ?
Many thanks. |
how to protect header & footer
Food afternoon Francois As regulars to these groups are aware, securely protecting contents of Excel spreadsheets is impossible. However the code below will not prevent users from changing the headers, but will reset the headers / footers to what you decide prior to printing. Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup ..LeftHeader = "header" ..CenterHeader = "" ..RightHeader = "" ..LeftFooter = "footer" ..CenterFooter = "" ..RightFooter = "" End With End Sub Place your headers / footers between the quotes above, empty quotes will remove any header or footer that has been inserted. As the procedure uses events it needs placing in the ThisWorkbook pane of the VBE. HTH DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=388326 |
how to protect header & footer
Tip :
Better change all sheets because it is possible that the user have more sheets selected Here a example http://www.rondebruin.nl/print.htm#Saved -- Regards Ron de Bruin http://www.rondebruin.nl "dominicb" wrote in message ... Food afternoon Francois As regulars to these groups are aware, securely protecting contents of Excel spreadsheets is impossible. However the code below will not prevent users from changing the headers, but will reset the headers / footers to what you decide prior to printing. Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup LeftHeader = "header" CenterHeader = "" RightHeader = "" LeftFooter = "footer" CenterFooter = "" RightFooter = "" End With End Sub Place your headers / footers between the quotes above, empty quotes will remove any header or footer that has been inserted. As the procedure uses events it needs placing in the ThisWorkbook pane of the VBE. HTH DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=388326 |
how to protect header & footer
Thanks for your answer. I was aware of the event beforeprint, but settings
the header and footer is a very slow process in Excel. Therefore I would have prefer to disable access to footer and header. Anyway Thanks. "dominicb" wrote: Food afternoon Francois As regulars to these groups are aware, securely protecting contents of Excel spreadsheets is impossible. However the code below will not prevent users from changing the headers, but will reset the headers / footers to what you decide prior to printing. Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup .LeftHeader = "header" .CenterHeader = "" .RightHeader = "" .LeftFooter = "footer" .CenterFooter = "" .RightFooter = "" End With End Sub Place your headers / footers between the quotes above, empty quotes will remove any header or footer that has been inserted. As the procedure uses events it needs placing in the ThisWorkbook pane of the VBE. HTH DominicB -- dominicb ------------------------------------------------------------------------ dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932 View this thread: http://www.excelforum.com/showthread...hreadid=388326 |
All times are GMT +1. The time now is 10:17 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com