Hello all,
I hope everyone is well today.
Thanks to tremendous user base on websites like this one along with a few others, I was able to customize the header and footer the way I need them to look with the use of macros & VBA language.
Just in case anybody wants to see the code I used that worked:
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.PageSetup.CenterHeader = "&C&16&B&K1F497DCompany: " & Worksheets("Sheet1").Range("A9").Value & vbCr & "2014"
ws.PageSetup.RightHeader = "&""Arial""&R&14&B&K632523Today " & "&K000000Work" & "&XTM"
Next ws
End Sub
However, after many days of attempts with various solution ideas I'm now stuck on an issue in which I'm in desperate need of some assistance.
The header & footer shows up on every page. I don't want it to appear on the first/cover page.
Below is a list of websites that inspired attempts at a solution but the list does not include every page I came across in this adventure:
- http://www.excelforum.com/excel-prog...irst-page.html
- http://www.mcgimpsey.com/excel/subs/firstfooter.html
- http://windowssecrets.com/forums/sho...el-s'sheet
I'm obviously not a VBA expert. I tried so many different methods and piecemealed code from so many different places that now it's kind of a giant cluster that probably doesn't make any sense to anyone at all, not even me.
Just for the sake of "showing my work" I'll share with you all where my mind is at right now. I'm sure many of you will think to yourselves, "That doesn't make any sense" and well, yeah, at this point I have no choice but to agree with you:
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
Dim wsSheet As Worksheet
Dim strLeftH As String
Dim strRightH As String
Dim strCenterH As String
Dim strLeftF As String
Dim strRightF As String
Dim strCenterF As String
For Each wsSheet In ActiveWindow.SelectedSheets
With wsSheet
strLeftH = .PageSetup.LeftHeader
.PageSetup.LeftHeader = ""
strCenterH = .PageSetup.CenterHeader
.PageSetup.CenterHeader = ""
strRightH = .PageSetup.RightHeader
.PageSetup.RightHeader = ""
strLeftF = .PageSetup.LeftHeader
.PageSetup.LeftHeader = ""
strCenterF = .PageSetup.CenterHeader
.PageSetup.CenterHeader = ""
strRightF = .PageSetup.RightHeader
.PageSetup.RightHeader = ""
.PrintOut From:=1, To:=1
.PageSetup.LeftHeader = strLeftH
strLeftH = "Risk Profile for"
.PageSetup.CenterHeader = strCenterH
strCenterH = "Risk Profile for"
.PageSetup.RightHeader = strRightH
strRightH = "Risk Profile for"
.PageSetup.LeftHeader = strLeftF
strLeftF = "Risk Profile for"
.PageSetup.CenterHeader = strCenterF
strCenterF = "Risk Profile for"
.PageSetup.RightHeader = strRightF
strRightF = "Risk Profile for"
.PrintOut From:=2
End With
Next wsSheet
End Sub
So right now I'm just at a complete loss in terms of what to do now. I'd appreciate any advice.
Thank you all for your time.
Bookmarks