簡體   English   中英

VBA Excel設置打印區域

[英]VBA excel setting print area

我正在使用命名范圍設置打印區域,因為它是一個表格並且會不斷增長。 當我執行時,標題將不會打印。 如何調整它以打印命名范圍(表3)和標題?

我試過了; ActiveSheet.PageSetup.PrintArea = Range("Table3{Headers}").Address但僅打印標題。

Application.Dialogs(xlDialogPrinterSetup).Show
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    Application.PrintCommunication = True
    ActiveSheet.PageSetup.PrintArea = Range("Table3").Address
    Application.PrintCommunication = False
    With ActiveSheet.PageSetup

我要打印標題和Table3。

表是ListObject 使用ListObject.Range屬性可返回表所引用的Range (包括標頭)。

Dim myTbl as ListObject
Set myTbl = ThisWorkbook.Sheets("mysheetname").ListObjects("Table3")
...
ThisWorkbook.Sheets("mysheetname").PageSetup.PrintArea = myTbl.Range.Address

根據需要更改工作表名稱。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM