【发布时间】:2022-12-08 20:47:03
【问题描述】:
我在 Internet 上找到了以下非常有用的 VBA 代码,但我想添加一个额外的步骤来将打印机上的设置更改为“在一页上显示所有列”。我怎样才能做到这一点?
Sub PrintFirstFilterItems()
'downloaded from contextures.com
'prints a copy of pivot table
'for each item in
'first Report Filter field
On Error Resume Next
Dim ws As Worksheet
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Set ws = ActiveSheet
Set pt = ws.PivotTables(1)
Set pf = pt.PageFields(1)
If pf Is Nothing Then Exit Sub
For Each pi In pf.PivotItems
pt.PivotFields(pf.Name) _
.CurrentPage = pi.Name
ActiveSheet.PrintOut 'for printing
'ActiveSheet.PrintPreview 'for testing
Next pi
End Sub
I need the code to change the printer settings to this
我是 VBA 的新手,我所做的只是在谷歌上搜索如何更改它,但没有任何效果。
【问题讨论】:
-
All of the options 但我认为这里特别重要的属性是 FitToPagesTall 和 FitToPagesWide