We have a little piece of VBA code that worked perfectly for ages. It was essentially:
Me.PivotTables("APivot").PivotFields("AField").CurrentPage = "Some text"
This worked until Excel 2013, where the line would fail with an unspecific error:
Runtime error 5:
Invalid procedure call or argument.
By trial and error we figured that in Excel 2013 you cannot navigate to a pivot table page with code until the user has navigated to that page manually using the Excel interface. As soon as the user navigates to a page, navigating to that page with code will always succeed (until you close the workbook). So in order for the code to be able to navigate to any page, we first need the user to go through all of them manually.
A workaround to that would be changing the value of the underlying cell instead:
Me.PivotTables("APivot").PivotFields("AField").CurrentPage.LabelRange.Value = "Some text"
We are currently forced to use this workaround, but it feels hackish.
Exactly what in Excel 2013 causes this behaviour? Is there some bit one now needs to do first in order to navigate to a page (poke something, load some data in some way etc)?
EDIT: Same problem occurs in Office 2016.