Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Printing to header/footer programatically
I would like to be able to set a message to print in the footer/header of a
printed page depending on certain criteria in the spreadsheet. Can someone suggest/advise how I could go about this. Thanks in advance Dean |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Printing to header/footer programatically
Dean,
A starter (from recording a macro as I added header and footer to a worksheet). Change the header /footer sections as required according to your selection criteria. e.g With ActiveSheet.PageSetup If condition = criteria then .LeftHeader=' .... whatever .." else .LeftHeader= " ... something else .." End If ..... End With Range("A1:J32").Select ActiveSheet.PageSetup.PrintArea = "$A$1:$J$32" With ActiveSheet.PageSetup ' Header Sections ....... .LeftHeader = "My Left Header Section" .CenterHeader = "My Centre Header Section" .RightHeader = "My Right Header Section" ' Footer sections ..... .LeftFooter = "My Footer Left" .CenterFooter = "My Footer Centre" .RightFooter = "My Footer Right" End With HTH "Dean" wrote: I would like to be able to set a message to print in the footer/header of a printed page depending on certain criteria in the spreadsheet. Can someone suggest/advise how I could go about this. Thanks in advance Dean |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Printing to header/footer programatically
You would want to put such code in the BeforePrint event. If you are not
familiar with events, see Chip Pearson's page on events http://www.cpearson.com/excel/events.htm -- Regards, Tom Ogilvy "Toppers" wrote in message ... Dean, A starter (from recording a macro as I added header and footer to a worksheet). Change the header /footer sections as required according to your selection criteria. e.g With ActiveSheet.PageSetup If condition = criteria then .LeftHeader=' .... whatever .." else .LeftHeader= " ... something else .." End If .... End With Range("A1:J32").Select ActiveSheet.PageSetup.PrintArea = "$A$1:$J$32" With ActiveSheet.PageSetup ' Header Sections ....... .LeftHeader = "My Left Header Section" .CenterHeader = "My Centre Header Section" .RightHeader = "My Right Header Section" ' Footer sections ..... .LeftFooter = "My Footer Left" .CenterFooter = "My Footer Centre" .RightFooter = "My Footer Right" End With HTH "Dean" wrote: I would like to be able to set a message to print in the footer/header of a printed page depending on certain criteria in the spreadsheet. Can someone suggest/advise how I could go about this. Thanks in advance Dean |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Printing to header/footer programatically
You can use VBA to set the BeforePrint to print the same footer
Private Sub Workbook_BeforePrint(Cancel As Boolean) With ActiveSheet If .Range("A1") = "my value" Then .PageSetup.LeftFooter = "Some text" End If End With End Sub 'This is workbook event code. 'To input this code, right click on the Excel icon on the worksheet '(or next to the File menu if you maximise your workbooks), 'select View Code from the menu, and paste the code -- HTH RP (remove nothere from the email address if mailing direct) "Dean" wrote in message ... I would like to be able to set a message to print in the footer/header of a printed page depending on certain criteria in the spreadsheet. Can someone suggest/advise how I could go about this. Thanks in advance Dean |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to prevent auto scaling of header and footer when printing | Excel Discussion (Misc queries) | |||
Excel 2007 - Header/Footer Printing problems | Excel Discussion (Misc queries) | |||
Template for printing-orientation, header-footer setup | Excel Worksheet Functions | |||
Changing Pivot Range Programatically - header row issue | Excel Programming | |||
Changing (Part of) Header Without Changing Footer or Rest of Header | Excel Programming |