我试着把一页的版面打印成pdf。
我选择范围,但是当我试图设置打印区域时,我得到:
运行时错误'1004':
无法设置PageSetup类的打印区域属性
Sub printpdftest()
Application.PrintCommunication = False
Application.Goto Reference:="'9. Requerimientos Custodia'!R6C1"
Dim myPath As String, myFile As String
myPath = ThisWorkbook.Path & "\"
firstDate = Format(Date, "ddmmyyyy")
myFile = Format(Date, "ddmmyy") & " 9.RC" & ".PDF"
Application.Goto Reference:="R6C1"
Selection.End(xlToRight).Select
ActiveCell.Offset(25, 0).Select
ActiveSheet.PageSetup.PrintArea = Range(Selection, "A1").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=myFile, Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=True
End Sub发布于 2022-01-27 16:08:11
PrintArea函数应该得到一个字符串作为输入。
因此不得不改变: ActiveSheet.PageSetup.PrintArea =Range(选择,"A1").Select
对于ActiveSheet.PageSetup.PrintArea =Range(选择"A1").Address
THX @RORY为解决方案
https://stackoverflow.com/questions/70881094
复制相似问题