Rx_
Nothing In Moderation
- Local time
- Today, 16:06
- Joined
- Oct 22, 2009
- Messages
- 2,803
Problem: Running the same .ActiveWorkbook.PivotCaches.Create a.k.a Create Pivot Table - in Excel vs MSAccess with remote automation:
The Excel SourceData can be columns $A:$CC and run.
From MSAccess using remote automation - it throws an OUT OF MEMORY error at the system level.
Question: is there a known limit to the size of the SourceData?
From MSAccess Objxl is set to an Excel.Application
Originally, used the Macro Recorder to build the code for creating a Pivot table based from data in a worksheet in the same workbook.
The code ran perfectly from within Excel (as a macro).
However, when converting the code to run in MSAccess as remote automation, the SourceData: was scaled down to work.
The concern is that later data may exceed 1,000. The average has been around 150 rows. If anyone has other suggestions, please contribute.
MSOffice 2016
B.T.W.
The code above works. Searching the web didn't return any good examples of creating a Pivot Table using VBA in Excel running the code from MS ACCESS.
The Excel SourceData can be columns $A:$CC and run.
From MSAccess using remote automation - it throws an OUT OF MEMORY error at the system level.
Question: is there a known limit to the size of the SourceData?
From MSAccess Objxl is set to an Excel.Application
Originally, used the Macro Recorder to build the code for creating a Pivot table based from data in a worksheet in the same workbook.
The code ran perfectly from within Excel (as a macro).
However, when converting the code to run in MSAccess as remote automation, the SourceData: was scaled down to work.
The concern is that later data may exceed 1,000. The average has been around 150 rows. If anyone has other suggestions, please contribute.
Code:
' ****************************************************************************
' Pivot TAbles AP Note Need to replace with relative reference
'******************************************************************************
Dim PivotSource As String
PivotSource = "AP Pmts 1025!$A100$:CC100"
CountWorksheets = Objxl.Worksheets.Count
Objxl.Sheets(CountWorksheets).Select
With Objxl
.Sheets.Add.Name = "AP Pmts Pivot" ' by default becomes current worksheet
.ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=.Worksheets(1).Range("$A1:$CC1000"), Version:=6).CreatePivotTable _
TableDestination:=.Worksheets("AP Pmts Pivot").Range("A3"), TableName:="PivotTable1", DefaultVersion _
:=6
.Cells(1, 1).Select
.ActiveSheet.PivotTables("PivotTable1").AddDataField .ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Transaction Value"), "Count of Transaction Value", _
xlCount
With .ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"Count of Transaction Value")
.Caption = "Sum of Transaction Value"
.Function = xlSum
End With
With .ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"Funding Business Unit - 6 Digit")
.Orientation = xlRowField
.Position = 1
End With
With .ActiveSheet.PivotTables("PivotTable1").PivotFields("Vlookup Project")
.Orientation = xlRowField
.Position = 2
End With
With .ActiveSheet.PivotTables("PivotTable1").PivotFields( _
"Correct Expenditure Type")
.Orientation = xlRowField
.Position = 3
End With
.ActiveSheet.PivotTables("PivotTable1").RowAxisLayout xlTabularRow
End With
MSOffice 2016
B.T.W.
The code above works. Searching the web didn't return any good examples of creating a Pivot Table using VBA in Excel running the code from MS ACCESS.