• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4065
  • Last Modified:

is possible to make a power view or power pivot using vba?


How can i make a vba code to create a power view or power pivot in excel? The macro recorder don't do anything. Any idea?
  • 2
1 Solution
x-menIT super heroCommented:

Sub PowerPivot()
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "Sheet1!R1C1:R4C2", Version:=xlPivotTableVersion12).CreatePivotTable _
        TableDestination:="Sheet1!R1C4", TableName:="PivotTable1", DefaultVersion _
    Cells(1, 4).Select
End Sub
Zack BarresseCEOCommented:
@x-men: They're asking for a PowerPivot creation, not a PivotTable.

@joyacv2: You must be using Excel 2010, in which case no, there is no VBA object model for PowerPivot. This was added in Excel 2013, although it's somewhat limited. Here is an example ...
    Workbooks("Book1").Connections.Add2 Name:="LinkedTable_Table1", Description:="", ConnectionString:="WORKSHEET;Book1", _
                                        CommandText:="Book1!Table1", lCmdType:=7, CreateModelConnection:=True, ImportRelationships:=False

Open in new window

Zack Barresse
joyacv2Author Commented:
so, there is no code to manipulate a power view or powerpivot, do you know any other alternative?
Zack BarresseCEOCommented:
As I said, if you're using 2010 there is no way to do this within Excel. Using 2013 there is an object model but it's not the most developed (since it's basically brand new). See http://msdn.microsoft.com/en-us/library/office/ff837594.aspx#xl15WhatsNew_NewDataSources

There is no object model for Power View.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now