一、在ThisWorkbook中,输入下列代码,保存后并运行
Sub test()
Application.PrintCommunication = False
Dim oWK As Worksheet
For Each oWK In ThisWorkbook.Worksheets
With oWK.PageSetup
'设置为打印重复行,1到3行
.PrintTitleRows = "$1:$3"
'设置打印重复列
.PrintTitleColumns = ""
End With
Next
Application.PrintCommunication = True
End Sub
二、创建模块,输入下列代码,保存后并运行
Private Sub Workbook_Open()
Application.PrintCommunication = False
Dim oWK As Worksheet
For Each oWK In ThisWorkbook.Worksheets
With oWK.PageSetup
'设置为打印重复行
.PrintTitleRows = "$1:$5"
'设置打印重复列
.PrintTitleColumns = ""
End With
Next
Application.PrintCommunication = True
End Sub