【问题标题】:Loop Through Each Print Page in Worksheet with VBA使用 VBA 循环遍历工作表中的每个打印页面
【发布时间】:2020-08-30 07:20:08
【问题描述】:

在 VBA 中,如何遍历工作簿中每个工作表的每个可打印页面并创建独特的页脚?我想在我的工作簿中放置“Page # of Numpages”。我有多个工作表,每个工作表都有多个打印页。

【问题讨论】:

    标签: excel vba printing footer


    【解决方案1】:
    Sub AddPageNumbersToFooters()
        Dim ws As Worksheet
    
        Dim numPages as Integer
        numPages = 0
    
        For Each ws In ThisWorkbook.Worksheets
            With ws.PageSetup
                .RightFooter = "Page &P+" & CStr(numPages) & " of "
                numPages = numPages + .Pages.Count
            End With
        Next wsTolStack
    
        For Each ws in ThisWorkbook.Worksheets
            With ws.PageSetup
                .RightFooter = .RightFooter & CStr(numPages)
            End With
        Next ws
    End Sub
    

    【讨论】:

      猜你喜欢
      • 2017-11-26
      • 1970-01-01
      • 2014-11-15
      • 2017-07-19
      • 2015-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-11
      相关资源
      最近更新 更多