从excel vba中设置适合Pdf中的Visible

Roh*_*uja 6 excel vba pdf-generation excel-vba

我正在尝试将excel工作表导出为pdf.有什么办法可以将pdf属性设置为fit to visible使用VBA.谢谢

以下是我正在使用的代码段

With wksSalesAndQuotaScoreCard
        '.PageSetup.LeftMargin=Application.InchesToPoints(0.7)
        .PageSetup.LeftMargin = Application.InchesToPoints(0.7)
        .PageSetup.RightMargin = Application.InchesToPoints(0.7)
        .PageSetup.TopMargin = Application.InchesToPoints(0.75)
        .PageSetup.BottomMargin = Application.InchesToPoints(0.75)
        .PageSetup.HeaderMargin = Application.InchesToPoints(0.3)

        .PageSetup.Orientation = xlLandscape
        .PageSetup.PrintTitleRows = "_SalesandQuotaScoreCardView"
        .PageSetup.CenterHorizontally = True
        .PageSetup.Order = xlDownThenOver
        .PageSetup.FitToPagesWide = 1
        ''.PageSetup.Zoom = 50
        Set rngSalesAndQuotaView = Range(.Shapes("_SalesandQuotaViewFrame").TopLeftCell.Offset(0, -1), .Shapes("_SalesandQuotaViewFrame").BottomRightCell.Offset(1, 0))
        rngSalesAndQuotaView.Select
    End With

    wksScoreCardPayoutView.Select
    wksSalesAndQuotaScoreCard.Select False
    Selection.ExportAsFixedFormat xlTypePDF, IncludeDocProperties:=True, openafterpublish:=True
    wksCustomizeScoreCard.Activate
Run Code Online (Sandbox Code Playgroud)

Lim*_*mak 1

如果我理解您的要求,您需要调整您的打印区域(因为导出到 PDF 就像打印)的宽度和高度。您已经有了该.PageSetup.FitToPagesWide = 1语句,现在您还需要.FitToPagesTall = 1,因此您的代码将如下所示:

    With wksSalesAndQuotaScoreCard
            '.PageSetup.LeftMargin=Application.InchesToPoints(0.7)
            .PageSetup.LeftMargin = Application.InchesToPoints(0.7)
            .PageSetup.RightMargin = Application.InchesToPoints(0.7)
            .PageSetup.TopMargin = Application.InchesToPoints(0.75)
            .PageSetup.BottomMargin = Application.InchesToPoints(0.75)
            .PageSetup.HeaderMargin = Application.InchesToPoints(0.3)

            .PageSetup.Orientation = xlLandscape
            .PageSetup.PrintTitleRows = "_SalesandQuotaScoreCardView"
            .PageSetup.CenterHorizontally = True
            .PageSetup.Order = xlDownThenOver
            .PageSetup.FitToPagesWide = 1
            .FitToPagesTall = 1
            ''.PageSetup.Zoom = 50
            Set rngSalesAndQuotaView = Range(.Shapes("_SalesandQuotaViewFrame").TopLeftCell.Offset(0, -1), .Shapes("_SalesandQuotaViewFrame").BottomRightCell.Offset(1, 0))
            rngSalesAndQuotaView.Select
    End With
Run Code Online (Sandbox Code Playgroud)

如果这不是解决方案,请解释一下这fittovisible对您来说是什么。