Forum

Notifications
Clear all

Protect the Header and Footer

10 Posts
5 Users
0 Reactions
773 Views
(@shumaker01)
Posts: 1
New Member
Topic starter
 

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!

 
Posted : 02/08/2016 9:28 pm
(@fravis)
Posts: 337
Reputable Member
 
Trying to figure this out, but I´m afraid it isn´t possible.

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?

 
Posted : 02/08/2016 9:35 pm
(@sunnykow)
Posts: 1417
Noble Member
 

@ 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.Laugh

 
Posted : 02/08/2016 9:43 pm
(@amisandip)
Posts: 15
Eminent Member
 

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.

 
Posted : 04/08/2016 10:13 pm
(@sunnykow)
Posts: 1417
Noble Member
 

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 Smile

 
Posted : 05/08/2016 2:09 am
(@amisandip)
Posts: 15
Eminent Member
 

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

 
Posted : 05/08/2016 5:44 am
(@catalinb)
Posts: 1937
Member Admin
 

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...

 
Posted : 05/08/2016 10:27 am
(@sunnykow)
Posts: 1417
Noble Member
 

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.

 
Posted : 05/08/2016 12:09 pm
(@catalinb)
Posts: 1937
Member Admin
 

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/

 
Posted : 06/08/2016 12:36 am
(@sunnykow)
Posts: 1417
Noble Member
 

Thanks for the link.

Done that before a couple of times. Lots of hiding and displaying sheets in my case. Smile

I guess it is just a matter of preference.

 
Posted : 06/08/2016 1:44 am
Share: