CommandBar Help

Adoh

New Member
Joined
Sep 6, 2006
Messages
8
Hi,

This is my first post, and this is probably a simple question

I am trying to create a toolbar which has a commandControlEdit(textfield)
and a commandControlButton(button)

I want a message box to pop up and give the name of the text in the text field.

BUT whenever i click the the button the text dissapears.

and my onAction method cannot capture the text befor it disappears


Can anyone Help
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Good evening Adoh

I don't believe this is possible.

It's very annoying because the Microsoft knowledge base says that an msoControlEdit box is simply an msoControlComboBox without the dropdown facility, but the user response from this type of control can be captured fairly easily.

Is an msoControlComboBox acceptable?

HTH

DominicB
 
Upvote 0
Hi DominicB,

To capture it,
I set the .onaction in the commandcontroledit

to a function i declare and pass the index

here is an example of how i did it:

13 is th id of the textfield
.OnAction = "'IDTables_Find """ & 13 & """'"


Sub IDTables_Find(textfields As Integer)

If textfields = 13 Then
findtext = CommandBars(thisButtonCaption).Controls(textfields).Text
End If


But i still do not know how to get it using the command button


end sub
 
Upvote 0
This worked for me:

Code:
Sub AddBar()
    Dim CB As CommandBar
    Dim CBC As CommandBarControl
    Set CB = CommandBars.Add
    With CB
        .Name = "MyBar"
        .Visible = True
        Set CBC = .Controls.Add(msoControlEdit)
        With CBC
            .Tag = "MyEdit"
        End With
        Set CBC = .Controls.Add(msoControlButton)
        With CBC
            .Tag = "MyButton"
            .Style = msoButtonIconAndCaption
            .Caption = "Get Text"
            .OnAction = "GetText"
        End With
    End With
End Sub

Sub GetText()
    MsgBox CommandBars("MyBar").FindControl(Type:=msoControlEdit, Tag:="MyEdit").Text
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,471
Messages
6,125,002
Members
449,202
Latest member
Pertotal

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top