Я в недоумении относительно того, в чем заключается проблема, связанная с этой ошибкой.Я смоделировал этот фрагмент кода из других отчетов, которые я сделал, где нет ошибок.Но этот не может получить свойство Function класса PivotFields.Я получаю эту ошибку, независимо от того, делаю я xlSum или XlCount
Function exportXl(strSD As String, strED As String) As String
Dim fname As String, fso As Object, xlApp As Object, xlBook As Object, xlSheet As Object, xlObj As Object, xlPT As Object, xlPC As Object, c As Object
fname = CurrentProject.Path & "\SupervisorEscalationsReport_" & Replace(strED, "/", "-") & ".xlsx"
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(fname) Then Kill fname
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12Xml, "t_SiebCnt", fname
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlBook = xlApp.workbooks.Open(fname)
Set xlSheet = xlBook.sheets(1)
With xlSheet
.Name = "t_SiebCnt"
Set xlObj = .ListObjects.Add(1, .Range("$A$1:" & .Cells(1, 1).SpecialCells(11).Address), , 1)
xlObj.Name = "Src_Table"
xlObj.TableStyle = "TableStyleMedium16"
End With
Set xlPC = xlBook.PivotCaches.Create(1, "Src_Table", 5)
Set xlSheet = xlBook.sheets.Add
xlSheet.Name = "Report"
xlApp.ScreenUpdating = False
Set xlPT = xlPC.CreatePivotTable(xlSheet.Range("A3"), "Supervisor Escalation Rollup Report")
With xlPT
With .PivotFields("AssignedToSalesID")
.Orientation = xlPageField
'.Position = 1
.Caption = "Sales ID"
End With
With .PivotFields("Location")
.Orientation = xlRowField
'.Position = 1
.Caption = "Site"
End With
With .PivotFields("FullName")
.Orientation = xlRowField
'.Position = 1
.Caption = "Supervisor Name"
End With
With .PivotFields("Generated_On")
.Orientation = xlRowField
' .Position = 2
.Caption = "Day Generated"
End With
With .PivotFields("Closed_On")
.Orientation = xlRowField
' .Position = 2
.Caption = "Day Closed"
End With
With .PivotFields("DaysOpen")
.Orientation = xlRowField
' .Position = 2
.Caption = "Days Open"
End With
With .PivotFields("Status")
.Orientation = xlRowField
' .Position = 2
.Caption = "Status"
End With
With .PivotFields("CountActivityUID")
.Orientation = xlDataField
.Function = xlCount
.NumberFormat = "#,##0"
.Caption = "Count of Status"
End With
.PivotFields("Day Generated").ShowDetail = False
.TableStyle2 = "PivotStyleMedium2"
.RowAxisLayout 1
.InGridDropZones = True
.DisplayErrorString = True
End With
Выше приведен полный код вместе с образцом создаваемой таблицымой сводный стол от.