Pages: 1
Print
Author Topic: How to control where a new top level menu item lands  (Read 911 times)
dcramer
Member

Posts: 120


« on: March 27, 2010, 01:33:47 PM »

Hi there,
I'm adding a new top level menu from a script:

Code:
var cmdBars = Application.CommandBars;
var menuBar = cmdBars.item("Menu bar");
var newTopMenu = menuBar.Controls.Add(5,,8); // Syntax error
newTopMenu.Caption = "&BroadBook";
// add more items here.

How can I make it land after the Windows menu and before the Help menu? When I add 8 as the third param, I get a syntax error.  I must not understand the reference docs:

"CommandBarControls_object.Add([intControlType], [variantCmdId], [variantBefore], [variantParam]);"

"variantBefore is a number that indicates the position of the new control in the collection; the new control is inserted before the control at this position. If this argument is omitted, the control is added at the end of the specified command bar. "

Thanks,
David
« Last Edit: March 27, 2010, 01:39:19 PM by dcramer » Logged

David Cramer
Technical Writer
Motive, an Alcatel-Lucent Company
dcramer
Member

Posts: 120


« Reply #1 on: March 27, 2010, 01:42:12 PM »

Nevermind. I found that if I add any number as the second param, then it works:

Code:
var newTopMenu = menuBar.Controls.Add(5,1,8);

The docs say "variantCmdId is an integer that specifies a built-in command to clone; if this argument is omitted, a blank custom control of the specified type is added to the command bar. "

It appears that you cannot omit this param. I'm not clear on what it does if I make the second param a 1 versus a 3.

Thanks,
David
Logged

David Cramer
Technical Writer
Motive, an Alcatel-Lucent Company
Pages: 1
Print
Jump to: