CreatePivotTable fails with Error 1004 on excel 2010

hsenul

New Member
Joined
Jul 30, 2015
Messages
2
I have following macro code that works fine on excel 2007 however when I try this on excel 2010 it fails with error 1004 - Application-defined or object-defined error. This seems to be excel version specific but I am not sure what is the cause of this error.

Has anyone faced similar issues or any suggestions how to work around this problem?

<code>
With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExternal)
.Connection = "OLEDB;Provider=MSOLAP; Initial Catalog=[OCWCube]; CreateCube=CREATE CUBE [OCWCube] ( DIMENSION [sp3Code], LEVEL [All] TYPE ALL," _
& " LEVEL [sp3Code], LEVEL [Book], LEVEL [PL Cat], LEVEL [Sec], LEVEL [Nominal], DIMENSION [Source], L" _
& "EVEL [All] TYPE ALL, LEVEL [Source], LEVEL [Daz Item], MEASURE [DailyUSD] FUNCTION SUM ); InsertInto=INSERT INTO O" _
& "CWCube([Source].[Source], [sp3Code].[sp3Code], [Book], [Sec], [Nominal], [PL Cat], [Daz Item], SKIPONECOLUMN, [DailyUS" _
& "D]) OPTIONS ATTEMPT_ANALYSIS " _
& strSQL _
& "; Source_DSN=""DSN=MS Access Database;DBQ=" _
& shtStat.Range("statDB") _
& ";DefaultDir=c:\temp;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"";"

.CommandType = xlCmdCube
.CommandText = Array("OCWCube")
.MaintainConnection = True
.CreatePivotTable TableDestination:=ActiveWorkbook.Worksheets("Dunzler").Cells(7, 2), TableName:="ptDazzler", DefaultVersion:=xlPivotTableVersion10
End With
</code>
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,215,417
Messages
6,124,789
Members
449,188
Latest member
Hoffk036

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top