Thread: Excel
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
KnightRiderAW KnightRiderAW is offline
external usenet poster
 
Posts: 20
Default Excel

I am trying to program a macro in Excel that when you run it, it puts the
date and time in the top-left header and the pathname in the bottom right
footer. I also want the worksheet in the center header. I have it where all
of this takes place. However, I want it to not label the center header if it
is the default name (Sheet1, Sheet2, Sheet3, etc.). Below is the programming
I have done, but I can't seem to get the Default name not to show. Can
anyone give me some help or advice. Thanks!

ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftHeader = "&D" & Chr(10) & "&T"
.CenterHeader = "&A"
If CenterHeader = "Sheet1" Then
CenterHeader = ""
End If
If CenterHeader = "Sheet2" Then
CenterHeader = ""
End If
If CenterHeader = "Sheet3" Then
CenterHeader = ""
End If
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = "&Z&F"
.LeftMargin = Application.InchesToPoints(0.75)
.RightMargin = Application.InchesToPoints(0.75)
.TopMargin = Application.InchesToPoints(1)
.BottomMargin = Application.InchesToPoints(1)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlPortrait
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = 100
.PrintErrors = xlPrintErrorsDisplayed
End With
End Sub

Aaron