VBA中的Excel报告设置页面设​​置选项

时间:2019-03-04 21:11:26

标签: excel vba excel-vba-mac

我想这样在Excel中列出我的可打印工作表:

Sl no  Sheet name Printable sheet number  Orientation Paper size
 1.     Sheet1     3                       Landscape   A4
 2.     Sheet2     2                       Portrait    lIgle

代码:

Sub printPages()
    Dim r As Long
    Dim s As Byte
    r = 5
    For s = 2 To ActiveWorkbook.Worksheets.Count
        Cells(r, 2).Value = Worksheets(s).Name
        Cells(r, 3).Value = Worksheets(s).PageSetup.Pages.Count
        Cells(r, 4).Value = Worksheets(s).PageSetup.XlPageOrientation.Value
        Cells(r, 5).Value = Worksheets(s).XlPaperSize.Name
        r = r + 1
    Next
End Sub

但是它不起作用。

0 个答案:

没有答案