Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Looking for a macro to enter a custom header and a footer
Header would have: title of worksheet job# client name date footer would have: file path author page# of total pages I saw how to create file paths and dates but I'm trying to combo everything into an easy to enter series of text boxes so our personnel don't have to open "page setup" each time... any suggestions would be appreciated Thanks -- jgbadingerjr |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
From VBA help files:
Worksheets("Sheet1").PageSetup.CenterHeader = "&D page &P of &N" You can also do: Sub heddft() Worksheets(1).PageSetup.CenterHeader = "&b &14 My Worksheet" _ & vbCrLf & "Job 1" & vbCrLf & "Some Client" & vbCrLf & "&d" End Sub For footer just substitute CenterFooter fow CenterHeader, or LeftHeader, LeftFooter, etc. It is all the same syntax. The &b and &14 and &d inside the quote marks set bold = true, Font size = 14 and Current date respectively. "jgbadingerjr" wrote: Looking for a macro to enter a custom header and a footer Header would have: title of worksheet job# client name date footer would have: file path author page# of total pages I saw how to create file paths and dates but I'm trying to combo everything into an easy to enter series of text boxes so our personnel don't have to open "page setup" each time... any suggestions would be appreciated Thanks -- jgbadingerjr |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi -
Here are a couple of options. Put either one in the ThisWorkbook module. Because a long pathname can encroach on the center footer, the second version 'stacks' the strings in the left footer. Version1: Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup 'worksheet title in A1 .LeftHeader = Range("A1") 'job# in A2 and client in A3 .CenterHeader = Range("A2").Value & " --- " & Range("A3") .RightHeader = Format(Date, "dd-mmm-yyyy") .LeftFooter = ThisWorkbook.FullName & Chr(13) ' or ThisWorkbook.Name .CenterFooter = ThisWorkbook.Author .RightFooter = "Page &P of &N" End With End Sub Version2: Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup 'worksheet title in A1 .LeftHeader = Range("A1") 'job# in A2 and client in A3 .CenterHeader = Range("A2").Value & " --- " & Range("A3") .RightHeader = Format(Date, "dd-mmm-yyyy") .LeftFooter = ThisWorkbook.FullName & Chr(13) & _ ThisWorkbook.Author & Chr(13) & _ "Page &P of &N" .CenterFooter = "" .RightFooter = "" End With End Sub -- Jay "jgbadingerjr" wrote: Looking for a macro to enter a custom header and a footer Header would have: title of worksheet job# client name date footer would have: file path author page# of total pages I saw how to create file paths and dates but I'm trying to combo everything into an easy to enter series of text boxes so our personnel don't have to open "page setup" each time... any suggestions would be appreciated Thanks -- jgbadingerjr |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
thanks for the help but im not sure where this goes...where is the ThisWorkbook Module? Thanks -- jgbadingerjr "Jay" wrote: Hi - Here are a couple of options. Put either one in the ThisWorkbook module. Because a long pathname can encroach on the center footer, the second version 'stacks' the strings in the left footer. Version1: Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup 'worksheet title in A1 .LeftHeader = Range("A1") 'job# in A2 and client in A3 .CenterHeader = Range("A2").Value & " --- " & Range("A3") .RightHeader = Format(Date, "dd-mmm-yyyy") .LeftFooter = ThisWorkbook.FullName & Chr(13) ' or ThisWorkbook.Name .CenterFooter = ThisWorkbook.Author .RightFooter = "Page &P of &N" End With End Sub Version2: Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet.PageSetup 'worksheet title in A1 .LeftHeader = Range("A1") 'job# in A2 and client in A3 .CenterHeader = Range("A2").Value & " --- " & Range("A3") .RightHeader = Format(Date, "dd-mmm-yyyy") .LeftFooter = ThisWorkbook.FullName & Chr(13) & _ ThisWorkbook.Author & Chr(13) & _ "Page &P of &N" .CenterFooter = "" .RightFooter = "" End With End Sub -- Jay "jgbadingerjr" wrote: Looking for a macro to enter a custom header and a footer Header would have: title of worksheet job# client name date footer would have: file path author page# of total pages I saw how to create file paths and dates but I'm trying to combo everything into an easy to enter series of text boxes so our personnel don't have to open "page setup" each time... any suggestions would be appreciated Thanks -- jgbadingerjr |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Right-click on the Excel Icon left of File on the menu bar or on the title bar
left of the filename if the sheet window is not maximized. Select "View Code". Paste the code into that module. Gord Dibben MS Excel MVP On Sat, 17 Mar 2007 16:29:09 -0700, jgbadingerjr wrote: Hi, thanks for the help but im not sure where this goes...where is the ThisWorkbook Module? Thanks |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you...all of you big help! 8)
-- jgbadingerjr "Gord Dibben" wrote: Right-click on the Excel Icon left of File on the menu bar or on the title bar left of the filename if the sheet window is not maximized. Select "View Code". Paste the code into that module. Gord Dibben MS Excel MVP On Sat, 17 Mar 2007 16:29:09 -0700, jgbadingerjr wrote: Hi, thanks for the help but im not sure where this goes...where is the ThisWorkbook Module? Thanks |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm using the following per the instructions below, and located at: http://www.cpearson.com/excel/headfoot.htm
However the 2 rows highlighted in Red are not pulling the Data from cells B2 and B3. Secondly I would like to make a Font Transition to 22PTS for for cells B2 and B3. Private Sub Workbook_BeforePrint(Cancel As Boolean) ActiveSheet.PageSetup.Leftheader = "&B&18&""Arial"" Stock: " Format (Worksheets("CALL_Profitability").Range("B2").Valu e) ActiveSheet.PageSetup.Centerheader = "&B&18&""Arial"" Option: " Format (Worksheets("CALL_Profitability").Range("B3").Valu e) End Sub Thanks, Hank |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
what code pulls in contents of a cell in an Excel header/footer? | Excel Discussion (Misc queries) | |||
Add Font to Header/Footer macro | Excel Discussion (Misc queries) | |||
Need some code for header/ footer, another case of "last saved | Excel Programming | |||
VB. NET Code to Change Excel Worksheet Header/Footer. | Excel Programming | |||
Header and Footer Macro | Excel Discussion (Misc queries) |