Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Printing all worksheets with sheetname in footer
Have a small task that I tried to solve with this macro:
Private Sub Workbook_BeforePrint(Cancel As Boolean) For Each wk In Worksheets ActiveSheet.PageSetup.LeftFooter = "&A" ActiveSheet.PrintOut Next End Sub Not very complex: Cycle through all sheets, for each and every sheet (the one active): - set left footer to show the Worksheet tab ("&A") - print it Any good advise from all of You ? Arild |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Printing all worksheets with sheetname in footer
How about:
Option Explicit Private Sub Workbook_BeforePrint(Cancel As Boolean) Dim wk As Worksheet For Each wk In Worksheets wk.PageSetup.LeftFooter = "&A" Next End Sub You were cycling through all the worksheets, but only changing the activesheet. And if you're in the _beforeprint routine, then it's gonna print unless you stop it. So I got rid of that line. Arild wrote: Have a small task that I tried to solve with this macro: Private Sub Workbook_BeforePrint(Cancel As Boolean) For Each wk In Worksheets ActiveSheet.PageSetup.LeftFooter = "&A" ActiveSheet.PrintOut Next End Sub Not very complex: Cycle through all sheets, for each and every sheet (the one active): - set left footer to show the Worksheet tab ("&A") - print it Any good advise from all of You ? Arild -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Printing all worksheets with sheetname in footer
Thanks a lot for raising those two major points of shortcoming in my coding
! "Dave Peterson" wrote in message ... How about: Option Explicit Private Sub Workbook_BeforePrint(Cancel As Boolean) Dim wk As Worksheet For Each wk In Worksheets wk.PageSetup.LeftFooter = "&A" Next End Sub You were cycling through all the worksheets, but only changing the activesheet. And if you're in the _beforeprint routine, then it's gonna print unless you stop it. So I got rid of that line. Arild wrote: Have a small task that I tried to solve with this macro: Private Sub Workbook_BeforePrint(Cancel As Boolean) For Each wk In Worksheets ActiveSheet.PageSetup.LeftFooter = "&A" ActiveSheet.PrintOut Next End Sub Not very complex: Cycle through all sheets, for each and every sheet (the one active): - set left footer to show the Worksheet tab ("&A") - print it Any good advise from all of You ? Arild -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Footer printing in wrong colour | Excel Discussion (Misc queries) | |||
Footer Printing Issue | Excel Discussion (Misc queries) | |||
Automatically update SheetName in workbook sub if SheetName changes | Excel Discussion (Misc queries) | |||
Can I set a default to add a filepath footer when printing? | Excel Discussion (Misc queries) | |||
Add filename to footer before printing using VBA | Excel Discussion (Misc queries) |