commandbar with own textfield for datetime input ??

  • Thread starter Thread starter Frank Huebener
  • Start date Start date
F

Frank Huebener

Hi,

is it possible to create an texfield in a commandbar and use it for my own
userinput (for example time input ?)

Application.CommandBars("mycommandbar").Controls.Add Type:=msoControlEdit

the command above is no problem i see an empty textfield in my commandbar
but how can i use it
in my excel macro ? i need it for date time input.

thanks for evry help

bye
frank
 
Give it a caption so you can refer to it.

Sub AddEditControl()
On Error Resume Next
Application.CommandBars("mycommandbar") _
.Controls("MyEditBox").Delete
On Error GoTo 0
With Application.CommandBars("mycommandbar") _
.Controls.Add(Type:=msoControlEdit)
.Caption = "MyEditBox"
.OnAction = "EditBox_click"
End With

End Sub

Sub EditBox_Click()
With Application.CommandBars("mycommandbar") _
.Controls("MyEditBox")
MsgBox .Text
End With

End Sub
 
Frank,

It's similar to other textboxes. Assuming you have set the Onaction property
of your control, in that macro use something like


MsgBox CommandBars.ActionControl.Text


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top