PDA

View Full Version : Solved: Problems with code when not in compatability mode



slang
08-25-2011, 02:38 AM
I have a workbook that I am migrating over to Excel 2010 from 2003. The code below works fine in compatability mode but not when its in XLSM.
Edit, the error I am getting is "Run time Error 5, Invalid proceedure call or argument" in the .current page call.
Let me guess, It all needs to change:motz2:
If it wasn't for wanting to control the @#%$ ribbon I would stay in cmode.

Sub dashboardcatchange()
ActiveSheet.Unprotect Password:="donttouch"
Dim cat As Integer
Application.ScreenUpdating = False
cat = Range("m21").Value
Range("b23").Select
Select Case cat
Case 1
ActiveSheet.PivotTables("PivotTable2").PivotFields("Cat").CurrentPage = "G"
Case 2
ActiveSheet.PivotTables("PivotTable2").PivotFields("Cat").CurrentPage = "A"
Case 3
ActiveSheet.PivotTables("PivotTable2").PivotFields("Cat").CurrentPage = "B"
Case 4
ActiveSheet.PivotTables("PivotTable2").PivotFields("Cat").CurrentPage = "C"
Case 5
ActiveSheet.PivotTables("PivotTable2").PivotFields("Cat").CurrentPage = "D"
Case 6
ActiveSheet.PivotTables("PivotTable2").PivotFields("Cat").CurrentPage = "U"
End Select
Range("C24").Select
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
Range("B15").Select
Application.ScreenUpdating = True
ActiveSheet.Protect Password:="donttouch"
End Sub

Thanks for any help you could provide.:help

Bob Phillips
08-25-2011, 04:21 AM
Can you post the workbook slang, saving us trying to invent the data.

Paul_Hossler
08-25-2011, 05:48 AM
The PT object model seems to have changed a lot over the last 7 years

I've found that using the macro recorder will at least identify the properties or methods that perform the function in 2010, and then I can incorporate those into the sub that I'm revising

Paul

slang
08-31-2011, 08:56 AM
Solved, was not the code at all. My Excel install was corrupted which caused complete havock with everything:banghead:

I now have a fresh dev box.