motherteresa
Board Regular
- Joined
- Nov 11, 2010
- Messages
- 81
I have a 2 tier problem. First, I helped to create a template with a lot of VBA work that several folks use in the field. To keep people from screwing things up, I password protected the VBA portion. Second, I need to update the footer in each of those workbooks. Each workbook has several worksheets.
So, is there a way to write a macro to a new workbook called...VBAPASS_FOOTER and just give a copy of that workbook to each field rep and have them run the macro to:
Here are some challenges that I'm not sure matter:
I've written the below code in one of my own workbooks to update the footer and it works well (feel free to improve it
). I placed it in the "ThisWorkbook" module, which also has some other code. But with so many workbooks to do for myself and the other field reps, it sure would help to automate the process if possible. Thanks in advance for any help.
So, is there a way to write a macro to a new workbook called...VBAPASS_FOOTER and just give a copy of that workbook to each field rep and have them run the macro to:
- Open all workbooks in a given field rep's folder (C:\WORKBOOKS) on their laptop and change the VBA code from xxx to edt123 without revealing what my original password was (the "xxx")?
- Update the footer on all sheets in each of those workbooks?
- Save the workbooks in the same folder with same name?
- Have a dialogue box pop up confirming the task of updating all the workbooks in the folder is done?
Here are some challenges that I'm not sure matter:
- When each workbook opens, a dialogue box opens to remind the user to do something. Hitting the enter key allows you to move into the workbook and begin working.
- Each worksheet already has a footer.
- Each worksheet is password protected.
- Each workbook has 9 worksheets. The first 7 need the update. The last 2 are hidden worksheets that don't.
- Some of the worksheets are landscape and some are portrait.
I've written the below code in one of my own workbooks to update the footer and it works well (feel free to improve it

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean) Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = ""
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.CenterFooter = _
"&""-,Bold""Education is FUN - Join us today"
.FooterMargin = Application.InchesToPoints(0.3)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = True
.CenterVertically = True
.Draft = False
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
.EvenPage.LeftHeader.Text = ""
.EvenPage.CenterHeader.Text = ""
.EvenPage.RightHeader.Text = ""
.EvenPage.LeftFooter.Text = ""
.EvenPage.CenterFooter.Text = ""
.EvenPage.RightFooter.Text = ""
.FirstPage.LeftHeader.Text = ""
.FirstPage.CenterHeader.Text = ""
.FirstPage.RightHeader.Text = ""
.FirstPage.LeftFooter.Text = ""
.FirstPage.CenterFooter.Text = ""
.FirstPage.RightFooter.Text = ""
End With
Application.PrintCommunication = True
End Sub