Jump to content
Sign in to follow this  
leo21cn

Help me create PivotTable

Recommended Posts

leo21cn

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
leo21cn

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
leo21cn

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.