leo21cn Posted June 7, 2009 Share Posted June 7, 2009 I have a big problem with pivottables. I can not add a PivotCache. Here is my code: $myRange = $myExcel.ActiveSheet.UsedRange $myCache = $myExcel.ActiveWorkbook.PivotCaches.Add(1, $myRange) It shows that type wrong. Them I changed like this: $myRange = $myExcel.ActiveSheet.UsedRange.Address $myCache = $myExcel.ActiveWorkbook.PivotCaches.Add(1, $myRange) There is no error showing. And IsObj($myCache) is True. But when I "MsgBox(0,"",$myExcel.ActiveWorkbook.PivotCaches.count)". It shows 0. And $myCache object can not create PivotTable because no any data. Could you help me? Please. Link to comment Share on other sites More sharing options...
leo21cn Posted June 7, 2009 Author Share Posted June 7, 2009 Sorry, forgot to say I'm using Excel COM object to create PivotTable. The first step - Create a PivotCache failed.I have a big problem with pivottables. I can not add a PivotCache.Here is my code:$myRange = $myExcel.ActiveSheet.UsedRange$myCache = $myExcel.ActiveWorkbook.PivotCaches.Add(1, $myRange)It shows that type wrong.Them I changed like this:$myRange = $myExcel.ActiveSheet.UsedRange.Address$myCache = $myExcel.ActiveWorkbook.PivotCaches.Add(1, $myRange)There is no error showing. And IsObj($myCache) is True.But when I "MsgBox(0,"",$myExcel.ActiveWorkbook.PivotCaches.count)". It shows 0.And $myCache object can not create PivotTable because no any data.Could you help me? Please. Link to comment Share on other sites More sharing options...
leo21cn Posted June 8, 2009 Author Share Posted June 8, 2009 The problem solved ... half . My code running well when using Excel XP but still wrong with Excel 2000.I think its because something changed between Excel 2000 and Excel XP. Sorry, forgot to say I'm using Excel COM object to create PivotTable. The first step - Create a PivotCache failed. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now