excel vba not exporting pagesetup to pdf correctly

后端 未结 3 1950
-上瘾入骨i
-上瘾入骨i 2020-12-11 05:41

I have code which formats a worksheet to the desired setup and layout (one page wide and tall in landscape). When I run the code (part of a long macro) it formats the pagese

3条回答
  •  天涯浪人
    2020-12-11 06:00

    I think the problem is that you need to add the .Zoom = False to your page setup code:

    'Format Print Area to one Page
    With ActiveSheet.PageSetup
        .PrintArea = Worksheets(ReportWsName).UsedRange
        .Orientation = xlLandscape
        .FitToPagesWide = 1
        .Zoom = False 'I have added this line
    End With
    

    From what I have tried this should solve it for you.

    Let me know how it goes!

    EDIT: Maybe you need:

    'Format Print Area to one Page
    With ActiveSheet.PageSetup
        .PrintArea = Worksheets(ReportWsName).UsedRange
        .Orientation = xlLandscape
        .FitToPagesWide = 1
        .FitToPagesTall = 1
        .Zoom = False 'I have added this line
    End With
    

    EDIT2: What if you changed:

    .PrintArea = Worksheets(ReportWsName).UsedRange

    To

    .PrintArea = Worksheets(ReportWsName).UsedRange.Address

提交回复
热议问题