Chrissirhc
Programmer
I have this code that creates a button, but it puts it on the top left hand corner of the screen. I'd like to dock it, but couldn't find the routine to do that... How does one do that?
Sub auto_open()
Dim myButtonBar As CommandBar
Dim myButton As CommandBarButton
Dim commandbarItem As CommandBar
Dim buttonBarAlreadyExists As Boolean
Set myButtonBar = CommandBars.Add
'Check if the morning star commandbar is already there and exit if it is.
For Each commandbarItem In CommandBars
If commandbarItem.Name = "myButtonBar" Then
Exit Sub
End If
Next commandbarItem
'Add the bar
With myButtonBar
.Name = "myButtonBar"
.Visible = True
.Top = 0
.Left = 0
End With
'Add the control a button
Set myButton = myButtonBar.Controls.Add(msoControlButton)
With myButton
'.FaceId = 300
.Style = msoButtonCaption
.OnAction = "LogInTo"
.Caption = "Log in to"
End With
End Sub
Thanks,
Chris
Sub auto_open()
Dim myButtonBar As CommandBar
Dim myButton As CommandBarButton
Dim commandbarItem As CommandBar
Dim buttonBarAlreadyExists As Boolean
Set myButtonBar = CommandBars.Add
'Check if the morning star commandbar is already there and exit if it is.
For Each commandbarItem In CommandBars
If commandbarItem.Name = "myButtonBar" Then
Exit Sub
End If
Next commandbarItem
'Add the bar
With myButtonBar
.Name = "myButtonBar"
.Visible = True
.Top = 0
.Left = 0
End With
'Add the control a button
Set myButton = myButtonBar.Controls.Add(msoControlButton)
With myButton
'.FaceId = 300
.Style = msoButtonCaption
.OnAction = "LogInTo"
.Caption = "Log in to"
End With
End Sub
Thanks,
Chris