title: Use VBA to capture the fields in pivot table
body: <p>We can use below code to build a Pivot Table (This is a pivot table created by Power Pivot).   </p>
  
  <pre><code>  With ActiveSheet.PivotTables("PivotTable1").CubeFields(FieldName)
              .Orientation = Orientation
              .Position = Position
  </code></pre>
  
  <p>Is there some way to reverse the process? Suppose user has built a pivot table. We use VBA to capture the fields used on the table (find out corresponding <code>FieldName(s), Orientation(s), and Position(s)</code>) and save them, so next time, user can just run the macro and create the same pivot table again.</p>
  
  <p>Thanks</p>