When you are going to create pdf or print your worksheet , you can use vba code. This will increase your efficiency. You can easily setup your page. Here I use Set the PrintCommunication property to False to speed up the execution of code that sets PageSetup properties. PrintTitleRows = "" means no title on page even multile pages atteached in the same file. If you use PrintTitleRows = "$1:$1" that means vba will setup the first column as Title. and when you use Chr(10) that means line break, we manually use it by pressing Enter Key. Set the PrintCommunication property to True after setting properties to commit all cached PageSetup commands. Using of &D&T means insert Date and Time.
The following example suspends communication with the printer while setting PageSetup properties.
- Sub Page_Setup()
- Application.PrintCommunication = False
- With ActiveSheet.PageSetup
- .PrintTitleRows = ""
- .PrintTitleColumns = ""
- End With
- Application.PrintCommunication = True
- ActiveSheet.PageSetup.PrintArea = ""
- Application.PrintCommunication = False
- With ActiveSheet.PageSetup
- .LeftHeader = ""
- .CenterHeader = "Report For" & Chr(10) & "Nsutradhar"
- .RightHeader = "&D&T"
- .LeftFooter = ""
- .CenterFooter = ""
- .RightFooter = ""
- .Orientation = xlPortrait
- End With
- Application.PrintCommunication = True
- End Sub
No comments:
Post a Comment