Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default adding uniform footers

Hi,

I am a VBA newbie and am not too good at tracing my way through the
object model tree. I want to give all the worksheets in 500 Excel files
a standard footer (but a different one if the sheet is a chart instead
of a data table). Here's what I have:

Sub StandardizeFooters()
Book As Workbook
Sheet As Worksheet
For Each Book In Workbooks
For Each Sheet In Book
With ActiveSheet.PageSetup
.LeftFooter = "&F"
.CenterFooter = "printed &D"
.RightFooter = "&P of &N"
End With
Next Sheet
Book.Close
Next Book
End Sub

Can anyone give me the correct syntax for a worksheet, as well as a way
to distinguish between sheets that are charts and those that aren't?
Thanks very much.

Jamie

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default adding uniform footers

Looks like you either need to specify more than the activesheet
e.g.
with Sheet.PageSetup ' NOT ACTIVESHEET

You should be able to cut your page setup code into this type of construct,
which loops sheet and charts.

Option Explicit

Sub Test()
Dim W As Workbook
Dim S As Worksheet
Dim C As Chart

For Each W In Workbooks
For Each S In wbook.Worksheets
Debug.Print "Book:", wbook.Name, "Sheet:", S.Name
'with S.Pagesetup etc

Next S

For Each C In wbook.Charts
Debug.Print "Book:", wbook.Name, "Chart:", C.Name
Next C


W.Save 'this saves the changes
W.Close(False) 'this closes the file with no prompt to save changes

Next W
End Sub

Good luck,

Robin Hammond
www.enhanceddatasystems.com
"Jamie Martin" wrote in message
...
Hi,

I am a VBA newbie and am not too good at tracing my way through the
object model tree. I want to give all the worksheets in 500 Excel files
a standard footer (but a different one if the sheet is a chart instead
of a data table). Here's what I have:

Sub StandardizeFooters()
Book As Workbook
Sheet As Worksheet
For Each Book In Workbooks
For Each Sheet In Book
With ActiveSheet.PageSetup
.LeftFooter = "&F"
.CenterFooter = "printed &D"
.RightFooter = "&P of &N"
End With
Next Sheet
Book.Close
Next Book
End Sub

Can anyone give me the correct syntax for a worksheet, as well as a way
to distinguish between sheets that are charts and those that aren't?
Thanks very much.

Jamie



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
uniform headers on Excel worksheets Timbertoe Setting up and Configuration of Excel 2 October 12th 06 09:56 AM
How do Print out a uniform spreadsheet i.e. all the same size A3 Dazza Excel Discussion (Misc queries) 0 November 29th 05 06:16 PM
how can i make a uniform timetable? student101 Excel Discussion (Misc queries) 1 March 15th 05 06:39 AM
Concatenate and make uniform JYowler Excel Worksheet Functions 2 November 2nd 04 10:50 PM
Concatenate and make uniform JYowler Excel Worksheet Functions 0 November 2nd 04 06:19 PM


All times are GMT +1. The time now is 06:42 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"