Below we will look at a program in Excel VBA that creates a footer before printing a workbook.
Create a Workbook BeforePrint Event. Code added to the Workbook BeforePrint Event will be executed by Excel VBA before you print a workbook.
1. Open the Visual Basic Editor.
2. Double click on This Workbook in the Project Explorer.
3. Choose Workbook from the left drop-down list. Choose BeforePrint from the right drop-down list.
4. To create a footer, add the following code line to the Workbook BeforePrint Event:
ActiveSheet.PageSetup.LeftFooter = ActiveWorkbook.FullName
Note: The PageSetup object contains all page setup attributes (left footer, bottom margin, paper size, left margin, and so on) as properties.
5. Test the program by printing your workbook.