|
||||||||
These pages are no longer updated and are only available for archive purposes.Click here to visit the pages with updated information. Apply a default header/footer using Custom ViewsThe macros below can be used to apply a default header/footer to a worksheet before it is printed. Any changes the user have made to the headers/footers will be overwritten and lost. Sub StoreDefaultViews() Dim strCurSheet As String, ws As Worksheet, strView As String If ActiveWorkbook Is Nothing Then Exit Sub Application.ScreenUpdating = False strCurSheet = ActiveSheet.Name With ActiveWorkbook For Each ws In .Worksheets ws.Activate strView = "DefaultView_" & ws.Name On Error Resume Next .CustomViews(strView).Delete .CustomViews.Add strView, True, True On Error GoTo 0 Next ws End With Sheets(strCurSheet).Activate End Sub Sub ApplyDefaultView() If ActiveWorkbook Is Nothing Then Exit Sub With ActiveSheet On Error Resume Next .Parent.CustomViews("DefaultView_" & .Name).Show On Error GoTo 0 End With End Sub Copy and paste the macro below into the ThisWorkbook module sheet: Private Sub Workbook_BeforePrint(Cancel As Boolean) ApplyDefaultView End Sub In Excel you can now press Alt+F8 and run the macro StoreDefaultViews to save the header/footer settings (and more).
Document last updated 2004-06-07 09:38:59
|
||||||||
|