我在Mac上使用Excel 2016。当我运行以下代码时,我收到一条错误,指出“打印时打印错误。”。按下确定后,我得到一个运行时错误'1004'。该错误发生在ExportAsFixedFormat行
中Public Sub RunAndSaveAllProperties()
'Routine which cycles through all properties in list and saves report as PDF
Dim myCell As Range, myName As String, myAccess As Boolean
'Cycle through properties in portfolio
For Each myCell In shtSettings.ListObjects("tblPropList").DataBodyRange.Columns(1).Cells
'Update Property to next in list
Me.Cells(2, 3).value = myCell.value
'Run Report
'Call UpdateGroupPaceReport (this will run the report; disabled for debugging)
'Do Events
DoEvents
'Save as PDF
myName = "Group Pace - " & Me.Cells(2, 3).value & " - " & Format(Me.Cells(3, 3), "YYYYMM") & ".pdf"
'Grant access to destination folder (not known if necessary)
myAccess = GrantAccessToMultipleFiles(Array(ThisWorkbook.Path))
If Not myAccess Then
'User denied access; exit sub
Call MsgBox("Access to Folder Denied. Please try again.", vbOKOnly + vbCritical, "Access Denied by User")
Exit Sub
End If
Me.ExportAsFixedFormat _
Type:=Excel.XlFixedFormatType.xlTypePDF, _
Filename:=myName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
'Do Events
DoEvents
Next myCell
End Sub
非常感谢任何帮助。