|
楼主 |
发表于 2023-3-11 22:52
|
显示全部楼层
Sub 定义页码及总页数名称()
ActiveWorkbook.Names.Add Name:="ColFirst", RefersToR1C1:= _
"=GET.DOCUMENT(61)" '判断打印顺序的设置类型
ActiveWorkbook.Names.Add Name:="ThisPageNo", RefersToR1C1:= _
"=IF(ISNA(MATCH(ROW(),GET.DOCUMENT(64))),1,MATCH(ROW(),GET.DOCUMENT(64))+1)" '获取当前页数
ActiveWorkbook.Names.Add Name:="PagesCount", RefersToR1C1:= _
"=GET.DOCUMENT(50)" '获取总页数
End Sub
Sub 批量设置页脚()
' 批量设置页脚 Macro
' 宏由 Bing 录制,时间: 2023-3-9
'
Dim ws As Worksheet '定义一个工作表对象
For Each ws In ActiveWorkbook.Worksheets '遍历工作簿中的所有工作表
With ws.PageSetup '访问工作表的页面设置属性
.CenterFooter = "&p/&n" '设置中页脚为当前页数/总页数
.RightFooter = "=TEXT(ThisPageNo,""第0页 "")&TEXT(PagesCount,""共0页"")" '设置右页脚为公式
End With
Next ws '继续下一个工作表
End Sub |
|