VBA/Excel/Access/Word/Excel/Worksheet Page Header Footer

Материал из VB Эксперт
Перейти к: навигация, поиск

Set center footer to your string text

 
Sub FilePathInFooter()
  Dim i As Integer
  
  For i = 1 To Worksheets.Count Step 1
    Worksheets(i).PageSetup.CenterFooter = "your center footer"
  Next i
End Sub



Set the center footer to file path

 
Sub FilePathInFooter()
  Dim i As Integer, FilePath As String
  
  FilePath = ActiveWorkbook.FullName
  For i = 1 To Worksheets.Count Step 1
    Worksheets(i).PageSetup.CenterFooter = FilePath
  Next i
End Sub



To print header, control the font and to pull second line of header (the date) from worksheet

 
Sub Printr()
    ActiveSheet.PageSetup.CenterHeader = "&""Arial,Bold Italic""&14My Report" & Chr(13) _
        & Sheets(1).Range("A1")
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
End Sub