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.
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.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.