Results 1 to 2 of 2
2006-01-25, 15:26 #1
- Join Date
- Apr 2001
- Thanked 0 Times in 0 Posts
Control values explaination (VBA)
In the following script, what do the ID and Before values set? I assumed that the ID would show the button's placement on a toolbar, but not sure about the Before value. Was trying to copy and paste to add multiple buttons, and found I did not know how to change those two values accordingly for each new button added.
Set oControl = oBar.Controls.Add(ID:=1, Before:=1)
oControl.OnAction = "InsertandCopy"
oControl.Style = msoButtonCaption
oControl.Caption = "InsertandCopy"
oControl.TooltipText = "Inserts New Columns/Rows and copies info"
Set oControl = Nothing
Set oBar = Nothing
Thanks - Sat.
2006-01-25, 15:35 #2
- Join Date
- Mar 2002
- Thanked 25 Times in 25 Posts
Re: Control values explaination (VBA)
The ID property of a commandbar control is always 1 for custom controls, and specifies the action for built-in controls. For example, the File | Open... menu item and the corresponding toolbar button both have ID = 23, and the Edit | Copy menu item and the corresponding toolbar button both have ID = 19. If you are creating buttons for user-defined macros, you don't need to specify ID, it will be 1 automatically.
The Before property specifies where you want to insert the new control created by Add. If you specify Before:=7, the new control will be inserted before (i.e. to the left of or above) the 7th control on the toolbar or menu. Before:=1 means insert at the very beginning. If you omit the Before argument, the control will be added at the end.