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?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

There is no object model for Power View.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.