Lanscaping
New Member
- Joined
- Dec 16, 2011
- Messages
- 5
When attempting to pull data out of SSAS2005 data cube on server into a pivot table on Windows desktop, I got this "Run-time error '1004' Application-defined or object-defined error" message. It happens everytime when I run this Macros. The section in red is the one the debug complaints. Any comment or feedback is welcomed.
Sub Macro1()
'
' Macro1 Macro
'
Workbooks("Book1").Connections.Add _
"Server-name Cube-name", "", Array( _
"OLEDB;Provider=MSOLAP.4;Integrated Security=SSPI;Persist Security Info=True;Data Source=Server-name;Initial Catalog= Data Catalog"), Array("Store"), 1
ActiveWorkbook.PivotCaches.Create(SourceType:=xlExternal, SourceData:= _
ActiveWorkbook.Connections("Server-name Store"), _
Version:=xlPivotTableVersion14).CreatePivotTable TableDestination:= _
"Sheet1!R1C1", TableName:="PivotTable1", DefaultVersion:= _
xlPivotTableVersion14
Cells(1, 1).Select
With ActiveSheet.PivotTables("PivotTable1").CubeFields( _
"[Store].[Store By Location]")
.Orientation = xlRowField
.Position = 1
End With
End Sub
Sub Macro1()
'
' Macro1 Macro
'
Workbooks("Book1").Connections.Add _
"Server-name Cube-name", "", Array( _
"OLEDB;Provider=MSOLAP.4;Integrated Security=SSPI;Persist Security Info=True;Data Source=Server-name;Initial Catalog= Data Catalog"), Array("Store"), 1
ActiveWorkbook.PivotCaches.Create(SourceType:=xlExternal, SourceData:= _
ActiveWorkbook.Connections("Server-name Store"), _
Version:=xlPivotTableVersion14).CreatePivotTable TableDestination:= _
"Sheet1!R1C1", TableName:="PivotTable1", DefaultVersion:= _
xlPivotTableVersion14
Cells(1, 1).Select
With ActiveSheet.PivotTables("PivotTable1").CubeFields( _
"[Store].[Store By Location]")
.Orientation = xlRowField
.Position = 1
End With
End Sub