VBA ExportAsFixedFormat为PDF,用于范围和更改输出的显示

时间:2017-08-04 10:24:52

标签: excel-vba vba excel

我有以下代码,将我想要的范围输出到PDF文件,并正确地适合一个肖像页面:

 With ActiveSheet.PageSetup
    .Orientation = xlPortrait
    .FitToPagesWide = 1
    .FitToPagesTall = 1
End With

rng.ExportAsFixedFormat _
    Type:=xlTypePDF, _
    Filename:=fSName, _
    Quality:=xlQualityStandard, _
    IncludeDocProperties:=False, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=False

但是,在我的PDF上,我左边有行字母,标题上面还有一个空白条,如下所示:

enter image description here

我怎样才能摆脱这些?我不希望它们显示出来,因为我已添加此部分,所以它们才出现:

 With ActiveSheet.PageSetup
    .Orientation = xlPortrait
    .FitToPagesWide = 1
    .FitToPagesTall = 1
End With

1 个答案:

答案 0 :(得分:1)

您需要设置

ActiveSheet.PageSetup.PrintHeadings = False

删除这些列和行标题。

With ActiveSheet.PageSetup
    .Orientation = xlPortrait
    .FitToPagesWide = 1
    .FitToPagesTall = 1
    .PrintHeadings = False
End With