Sign in to follow this  
Followers 0
leo21cn

Help me create PivotTable

3 posts in this topic

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.

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

The problem solved ... half :D .

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0