Jump to content

Help me create PivotTable


leo21cn
 Share

Recommended Posts

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

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

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...