Create a pivot table with a local connection

N

Nir

Hi,

On Excel 2003 SP2:
I'm trying to create a pivot table with a pivot cache connected to a local
cube file as follows:

Sub Macro1()
With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExternal)
.LocalConnection = "OLEDB;Provider=MSOLAP;Data Source=C:\Documents
and Settings\nir.zamir\Desktop\Basic Metrics.cub"
.UseLocalConnection = True
.CommandType = xlCmdCube
.CommandText = Array("AdvertisingDataMain")
.MaintainConnection = True
.CreatePivotTable TableDestination:="[Book1]Sheet1!R3C1",
TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
End With
End Sub

However, the UseLocalConnection line throws an error (run time error 1004 -
application-defined or object-defined error).

What could be the reason?

Thanks,
Nir
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top