Excel自动化 - 打印整个工作簿设置

时间:2011-05-20 19:54:28

标签: c++ printing automation excel

在Excel对象库中是否有一个界面来设置打印首选项以打印整个工作簿而不是活动工作表?

1 个答案:

答案 0 :(得分:0)

不,PageSetup仅适用于工作表

您可以做的最好是复制所需设置的宏

Sub CopyPageSetup()
    Dim sh As Worksheet, cl As Range
    Dim shBase As Worksheet

    Set shBase = ActiveSheet
    For Each sh In ActiveWindow.SelectedSheets
        If sh.Name <> shBase.Name Then
            sh.PageSetup.Orientation = shBase.PageSetup.Orientation
            ' Add other PageSetup properties here '
            ' unfortunately sh.PageSetup = shBase.PageSetup does not work '
        End If
    Next

End Sub