I am currently trying to figure out how to protect the header/footer. I seem to be able to lock 'everything' in my worksheet/ workbook EXCEPT the header and footer, so these remain subject to modification by others. Is there a way to protect these? Thank you for any insights!
I thought maybe a workaround could be to use ´view´ and then ´custom views´, cause you can do something with the print settings, but this doesn´t influence it the way you want it.
Maybe somebody else has a workaround?
@ Laurie-E
Protection is only meant to prevent accidental entering of data and not 100% full proof. As I know, what you ask may not be possible (not that l am aware of). In my opinion you will have to educate your users not to amend things that they are not suppose to touch. I always tell my users if they do this on purpose, I will not be responsible for any loss or incorrect info. Lucky for me they always listens, otherwise l will complain to their superiors.
Using VBA you can write a Workbook.BeforePrint event where you can mention what is to be written in Header Footer. So even if someone writes something in Header Footer your code will replace that before print.
Yes, you can use VBA but it is still not "protecting" the header or footer, rather it is overriding it during printing.
If you have many worksheets with different headers and footers, then you will need to do it for every one of them.
If it is acceptable then go ahead and use what was suggested by amisandip
Even if you have many worksheets with different headers and footers, still you will need NOT to do it for every one of them. Say the value stored in cell A1 of every sheet you want to put it in sheet's header, then it is possible by executing this code:
Sub AddHeaderToAll_FromEachSheet()
'Add A1 from each sheet to that sheet's header
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.PageSetup.LeftHeader = ws.Range("A1").Value
Next ws
End Sub
For more ideas in regards to this and for detailed instruction you can visit http://www.vbaexpress.com/kb/getarticle.php?kb_id=739
Maybe disabling the menu item will help, I've seen some codes for that. Users will not be able to open the Headers and Footers menu to make changes:
Private Sub Workbook_Open()
Application.CommandBars("Worksheet menu bar"). _
Controls("View").Controls("&Header and Footer...").Enabled = False
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CommandBars("Worksheet menu bar"). _
Controls("View").Controls("&Header and Footer...").Enabled = True
End Sub
Of course, if they do not enable macros, there will be a problem...
I agree with you Catalin that you cannot force user to enable macros. We can find many work-arounds but all will fail because of this.
From my own personal experience, education is still the best way for me.
Well, there are ways to force users to enable macros.
What if you hide all the sheets from the workbook, and display just a message? They have no other choice than to enable macros if they want to see and use the sheets. See this link for a functional example: /hide-excel-sheets-if-macros-are-not-enabled/
Thanks for the link.
Done that before a couple of times. Lots of hiding and displaying sheets in my case.
I guess it is just a matter of preference.