View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Aparna Rege Aparna Rege is offline
external usenet poster
 
Posts: 3
Default Triggering click event of a menu in vba

Steve,

I found a way to bring up the wizard, I can use Execute property of
commandbarcontrol.

I had already tried to use the macro, but that did not help. It would not
let me stop the macro recording until I go though all the steps in the
wizard. And it records something like this:

With ActiveWorkbook.PivotCaches.Add(SourceType:=xlExter nal)
.Connection = _
"OLEDB;Provider=MSOLAP.2;Data Source=TESTWIN2KS;Initial
Catalog=TESTDB;Client Cache Size=25;Auto Synch Period=10000"
.CommandType = xlCmdCube
.CommandText = Array("SalesDetail")
.MaintainConnection = True
.CreatePivotTable TableDestination:="[Book5]Sheet1!R3C1",
TableName:= _
"PivotTable5", DefaultVersion:=xlPivotTableVersion10
End With

What I am trying to do is: bring up the wizard window the first time (user
selects a custom created menu).
Next time after user selects another option from the same menu, use the
information he selected in the wizard the first time and take him to the
third or fourth window in the wizard. I thought recording macro is the way
to do it, but it seems it's not.

Thanks,
Aparna

"steve" wrote in message
...
Aparna,

This is a good opportunity to use the macro recorder.

Turn on the recorder and manually go through the steps of setting up the
Pivot Table. Turn off the recorder and than edit the code to suit your
needs. Remember that the recorder will record "more" than you really

need,
and that it fixes the ranges to what you used.

Post back with your code and additional questions if you need help.

steve

"Aparna Rege" wrote in message
...
Hi,

I want to trigger the code behind an Excel commandbar button through vba
code without user selecting the command. To be specific I want to bring

up
the 'Pivot Table and PivotChart Wizard' (Data PivotTable and

PivotChart
Report) programmatically.
Does anybody know how to do this?

Thanks in advance,
Aparna