W
WirelessPete
I have an Excel 2007 application that connects to an OLAP database using a
pivot table. When the user changes a list box value in the workbook I refresh
the pivot table, which generates a new OLAP query. Works fine until the
spreadsheet sits for more than about 5 minutes, then I get a "Run-Time error
1004 Application defined or object defined error" on the first ActiveSheet
line.
Sub Update_CarrierDetailData(ByVal CurrentMarket As String, ByVal
CurrentSector As String)
Dim strCurrentSheet As String
Dim strCurrentCell As String
strCurrentSheet = ActiveSheet.Name
strCurrentCell = ActiveCell.Address
Sheets("CarrierDetail").Select
ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Carrier].[Market].[Market]").ClearAllFilters
ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Carrier].[Market].[Market]").CurrentPageName = _
"[Carrier].[Market].&[" & CurrentMarket & "]"
ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Carrier].[Sector].[Sector]").CurrentPageName = _
"[Carrier].[Sector].&[" & CurrentSector & "]"
Sheets(strCurrentSheet).Select
Range(strCurrentCell).Select
End Sub
pivot table. When the user changes a list box value in the workbook I refresh
the pivot table, which generates a new OLAP query. Works fine until the
spreadsheet sits for more than about 5 minutes, then I get a "Run-Time error
1004 Application defined or object defined error" on the first ActiveSheet
line.
Sub Update_CarrierDetailData(ByVal CurrentMarket As String, ByVal
CurrentSector As String)
Dim strCurrentSheet As String
Dim strCurrentCell As String
strCurrentSheet = ActiveSheet.Name
strCurrentCell = ActiveCell.Address
Sheets("CarrierDetail").Select
ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Carrier].[Market].[Market]").ClearAllFilters
ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Carrier].[Market].[Market]").CurrentPageName = _
"[Carrier].[Market].&[" & CurrentMarket & "]"
ActiveSheet.PivotTables("PivotTable2").PivotFields( _
"[Carrier].[Sector].[Sector]").CurrentPageName = _
"[Carrier].[Sector].&[" & CurrentSector & "]"
Sheets(strCurrentSheet).Select
Range(strCurrentCell).Select
End Sub