Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default Excel Pivot Table - Get data in Pivot Field

Hi -

Basic question: How can I iterate through the items in a Pivot Table report
filter?

So lets say a pivot table contains a "Car Model" report filter with elements
such as "Chevy", "Olds", "Toyota", etc. For starters I just want to be
iterate through the Car Model filter and show each element in a MessageBox
(just to get the hang of it).

Other notes:
I'm automating Excel 2007 via C# and VSTO.
The PivotTable data source is an OLAP cube stored on a server
While I'd like a C# snippet I'll take VB.Net (and even VBA, but third choice)
What I really want to do is change the selected element to "Chevy", print
the page, select "Olds", print the page, select "Toyota", print the page ....

My code so far:

Excel.PivotTable pvt =
(Excel.PivotTable)Globals.Sheet1.PivotTables("Pivo tTable1");
Excel.PivotField fld = (Excel.PivotField) pvt.PivotFields("[Contract
Info].[Model].[Model]");
fld.CurrentPageName = "[Contract Info].[Model].&[Chevy]"; //<- Changes the
filter from "All" to "Chevy"
// Code works to this point

But I can't figure out how to expose the values in the PivotField (psudo
code along the lines of:)
foreach (PivotItem item in fld.PivotItems)
MessageBox.Show(item.Name)


Thanks for any suggestions
Mark

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot table field data Steve 51 Excel Discussion (Misc queries) 1 February 9th 09 08:35 PM
Sorting Page Area Field Data in Excel 2007 Pivot Table Rubble Excel Discussion (Misc queries) 2 February 17th 08 03:51 PM
Pivot Table Data field Dan McCollick Excel Programming 2 April 10th 06 06:09 PM
Excel Pivot Table Appends a '2' to the field data items SunshineX Excel Discussion (Misc queries) 1 October 4th 05 08:06 PM
Update Data Field in Pivot Table with Dynamic Excel Range ExcelMonkey[_97_] Excel Programming 1 March 3rd 04 08:16 PM


All times are GMT +1. The time now is 10:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"