title: Why is this PivotItem.Visible call throwing a TypeMismatch error?
body: <p>This is baffling us. I have a standard pivot table with a report filter on it that allows multiple selection of items. I can get the selected items in the report filter with:</p>
  
  <pre><code>Dim pi As PivotItem
  For Each pi In PivotTables("MyPivot").PivotFields("MyField").PivotItems
      If pi.Visible Then
          Debug.Print pi.Value
      End If
  Next
  </code></pre>
  
  <p>Simple. My collegue has a standard pivot table with a report filter on it that allows multiple selection of items. He tries getting selected items in the report filter with <em>the same code</em>:</p>
  
  <pre><code>Dim pi As PivotItem
  For Each pi In PivotTables("HisPivot").PivotFields("HisField").PivotItems
      If pi.Visible Then
          Debug.Print pi.Value
      End If
  Next
  </code></pre>
  
  <p>And gets a Type Mismatch error on <code>pi.Visible</code>. We know that <code>Visible</code> is a property in <code>pi</code>, as after typing <code>pi.</code> the intellisense appears with all the <code>PivotItem</code> properties and methods (as you'd expect). We know that pi contains a valid PivotItem, as calling <code>pi.Value</code> prints the value correctly (removing the <code>If</code>/<code>End If</code> statements to just let it print the value regardless will print every item in the list). There is nothing 'special' about his report filter - it isn't a calculated field or anything like that. Most other properties of <code>PivotItem</code> also fail.</p>
  
  <p>Does anyone know why <code>PivotItem</code> would show this behaviour? The <a href="http://msdn.microsoft.com/en-us/library/ff821060%28v=office.14%29.aspx" rel="nofollow">MSDN reference</a> seems rather inadequate.</p>