access pivot fields via automation (1 Viewer)

gebuh

Registered User.
Local time
Today, 08:38
Joined
Jun 16, 2006
Messages
21
Hi all-can anyone tell me what I'm doing wrong here? I'm trying to copy the page, row and column fields in an existing excel pivotTable from access using automation- I'm trying to automate a report from a pivotTable. No matter how I do it I keep getting errors while trying to start the excel app. I've been able to create an excel spreadsheet and pivots using automation, but using automation to access them isn't working. As of now I'm getting error "91 object variable or with block variable not set"
thanx

Code:
Public Function getExcelStuff()
'get pivot row and column data from excel
On Error GoTo Err_getExcelStuff

    Dim objXLApp As Excel.Application
    Dim objXLBook As Excel.Workbook
    Dim pvtTable As PivotTable
    Dim pvtField As PivotField
    
    Set objXLBook = GetObject("C:\rcaTest\xPivot.xls")
    Set objXLApp = objXLBook.Parent
    Set pvtTable = objXLBook.ActiveChart.PivotLayout.PivotTable
    

Exit_getExcelStuff:
    Exit Function

Err_getExcelStuff:
    MsgBox Err.Number & " - " & Err.Description
    Resume Exit_getExcelStuff
    

End Function
 

Users who are viewing this thread

Top Bottom