VBA - 1页面设置与休息(未知#)页面不同

时间:2017-09-28 14:00:33

标签: excel-vba vba excel

我正在尝试在具有相同范围的多张纸上进行页面设置。但是,其中一张表"仪表板"有不同的页面设置范围。它将是" D24:K73"如何使用下面的代码实现这一目标?我试过修改它,但我的技能没有产生想要的结果。

 Sub Octsaveaspdf()
 Dim ws As Worksheet
 Dim FileName As String
 Dim FilePath As String
   For Each ws In Sheets
     If ws.Visible Then ws.Select (False)
   Next

   FilePath = Range("Instructions!B16").Value
   FileName = Range("Dashboard!Q26").Text
     Range("$p24:$w73").Select
     Application.PrintCommunication = False
     With ActiveSheet.PageSetup
     LeftMargin = Application.CentimetersToPoints(0.1)
    .RightMargin = Application.CentimetersToPoints(0.1)
    .FitToPagesWide = 1
    End With

  Application.PrintCommunication = True
  ActiveSheet.ExportAsFixedFormat _
  Type:=xlTypePDF, FileName:=FilePath & "Compare " & FileName & ".pdf" _
    , Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=True

End Sub  

我非常感谢所有的帮助:)谢谢!

1 个答案:

答案 0 :(得分:0)

将导出移动到单独的过程中,并使用不同的范围多次调用以导出。

以下代码将处理每个可见的工作表,并根据工作表名称导出不同的范围 每个导出都将使用相同的名称,因此您需要对此进行一些操作以阻止文件名冲突的问题。

required init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)!
    //Redirect for push notification
    NotificationCenter.default.addObserver(self, selector: #selector(self. catchIt), name: NSNotification.Name(rawValue: "myNotif"), object: nil)
}
相关问题