Hi There,
I have a custom commandbar wich I like to have positioned next to the already excisting 'standard' commandbars of Excel.
Now whatever position I give it, it will NOT be placed next to it. The only place it appears is below the excisting commandbars.
Is there a solution for this?
The current code is like:
(Still in testing fase....)
I have a custom commandbar wich I like to have positioned next to the already excisting 'standard' commandbars of Excel.
Now whatever position I give it, it will NOT be placed next to it. The only place it appears is below the excisting commandbars.
Is there a solution for this?
The current code is like:
(Still in testing fase....)
Code:
Sub PositionCommandBar()
With CommandBars("DLmenu")
.Position = msoBarTop
.Left = 850
.Top = 5
End With
End Sub
Sub Create_DLMenu()
Dim MyBar As CommandBar
Dim MyPopup As CommandBarPopup
Dim MyButton As CommandBarButton
' Delete the commandbar if it exists already
On Error Resume Next
Application.CommandBars("DLmenu").Delete
Set MyBar = CommandBars.Add(Name:="DLmenu", _
Position:=msoBarFloating, temporary:=True)
With MyBar
'.Top = 175
'.Left = 850
Set MyPopup = .Controls.Add(Type:=msoControlPopup)
With MyPopup
.Caption = "DL_menu"
.BeginGroup = True
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "yellow" 'this the text
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption, or msoButtonIconandCaption
.BeginGroup = True
.OnAction = "yellow" 'macro to be run,change to EmailSLA
End With
'this code to add another button
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "chicken"
.Style = msoButtonCaption
.BeginGroup = False
.OnAction = "chicken"
End With
End With
Set ComBarContrl = MyBar.Controls.Add(Type:=msoControlButton)
With ComBarContrl
'the facId line will let you choose an icon
' If you choose to use the faceId then the caption is not displayed
.BeginGroup = True
.FaceId = 1000
.Caption = "Icon Button"
.TooltipText = "Run Macro2"
'the onaction line tells the button to run a certain macro
.OnAction = "Macro2"
End With
Set ComBarContrl = MyBar.Controls.Add(Type:=msoControlButton)
With ComBarContrl
'the facId line will let you choose an icon
' If you choose to use the faceId then the caption is not displayed
.BeginGroup = False
.FaceId = 1000
.Caption = "Icon Button"
.TooltipText = "Run Macro2"
'the onaction line tells the button to run a certain macro
.OnAction = "Macro2"
End With
'.Width = 150
.Visible = True
End With
Call PositionCommandBar
End Sub