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

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

Set center footer to your string text

   <source lang="vb">

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

</source>
   
  


Set the center footer to file path

   <source lang="vb">

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

</source>
   
  


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

   <source lang="vb">

Sub Printr()

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

End Sub

</source>