Results 1 to 1 of 1

PivotCaches.add Error 5 - 2003 to 2010 Macros

Threaded View

  1. #1
    Registered User
    Join Date
    08-08-2012
    Location
    Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    3

    PivotCaches.add Error 5 - 2003 to 2010 Macros

    I have a 2003 Excel xls file that I am trying to run in Excel 2010. I first saved the file as a xlsm and added the directory as trusted in Trust Center. I am getting an error code in the red. Note: If I change the PivotTableVersion to 12, it still gives me the same error. Code is below. Thank you in advance for your help!

    Sub Create_pivot()
        Wbname = ActiveWorkbook.Name
    '   Insert columns to make room for pivot table
        Columns("A:I").Select
        Selection.Insert Shift:=xlToRight
        myData = Sheets(ActiveSheet.Name).[J1].CurrentRegion.Address
        mySheet = ActiveSheet.Name & "!"
        tableDest = "[" & Wbname & "]" & mySheet & "R1C1"
        ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
            mySheet & myData).CreatePivotTable TableDestination:=tableDest, TableName _
            :="RTP_alerts", DefaultVersion:=xlPivotTableVersion10    
        With ActiveSheet.PivotTables("RTP_alerts").PivotFields("Application")
            .Orientation = xlRowField
            .Position = 1
        End With
        With ActiveSheet.PivotTables("RTP_alerts").PivotFields("Object")
            .Orientation = xlRowField
            .Position = 2
        End With
        ActiveSheet.PivotTables("RTP_alerts").AddDataField ActiveSheet.PivotTables( _
            "RTP_alerts").PivotFields("Alerts"), "Count of Alerts", xlCount
        ActiveWorkbook.ShowPivotTableFieldList = False
        Application.CommandBars("PivotTable").Visible = False
        
        Columns("G:I").Select
        Selection.Delete Shift:=xlToLeft
        Range("D2").Select
        ActiveCell.FormulaR1C1 = "Owner"
        Range("E2").Select
        ActiveCell.FormulaR1C1 = "Problem Ticket"
        Columns("E:E").ColumnWidth = 13
        Range("F2").Select
        ActiveCell.FormulaR1C1 = "Comments"
        Columns("F:F").ColumnWidth = 48
    End Sub
    Last edited by rupes0610; 08-08-2012 at 09:40 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1