Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Footer printing in wrong colour Jimmyschniz Excel Discussion (Misc queries) 0 January 18th 10 03:00 PM
Footer Printing Issue Liquid Excel Discussion (Misc queries) 0 February 19th 09 04:31 PM
Automatically update SheetName in workbook sub if SheetName changes [email protected] Excel Discussion (Misc queries) 3 February 29th 08 04:33 PM
Can I set a default to add a filepath footer when printing? bearcat1 Excel Discussion (Misc queries) 0 August 3rd 06 09:21 PM
Add filename to footer before printing using VBA PCE Man Excel Discussion (Misc queries) 5 December 2nd 04 10:55 PM


All times are GMT +1. The time now is 07:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"