Ask Your Question

How to trigger a combobox "Execute action" event.

asked 2018-06-04 05:42:57 +0100

hvankampen gravatar image

I would like to know exactly what action or macro code would trigger an "Execute action" event in a combobox in a Calc dialog object. I know selecting a different value from the value list in a listbox will trigger this event, but what would trigger this event in a combobox?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-06-04 07:24:16 +0100

Ratslinger gravatar image

updated 2018-06-05 05:54:29 +0100


Events in a combo box are nearly identical to that of a list box.

Description of events can be found here -> Events.

It may help if you were to state what you are looking to accomplish.

Edit 2018-06-04:

To accomplish your request, the macro should be attached to the Key pressed event. This will call the macro for each keystroke:

Sub KeyHandler_KeyPressed(oEvent)
    If oEvent.Source.SelectedText = oEvent.Source.Text Then
        Print "Selection is from list"
        Exit sub
    End If
    If oEvent.KeyCode = OR oEvent.KeyCode = Then
    End If
End Sub

Sub EnterPressed(oEvent)
    iItems = oEvent.Source.ItemCount
    sText = oEvent.Source.Text
    For x = 0 to iItems -1
       If oEvent.Source.getItem(x) = sText Then
          Print "Entered item IS in list."
          Exit sub
       End if
    Print "Entered item is NOT in list!"
End Sub

First checked is SelectedText vs Text & if equal the an item was selected from list. If not equal check if RETURN key was pressed. If not, allow further entry to proceed. Once the enter key is pressed the entry may be one in the list but entered manually ( in other words not selected ). The entered text must then be checked against the list to see if there was a match. This second check is necessary because there was nothing actually selected (entry completely typed in) but still may be in the list already (short entry ie: red)

To answer you other question, the "Item Status Changed" event is triggered when a different item is selected from the list - triggered without ENTER key being used.

If this answers your question please tick the ✔ (upper left area of answer). It helps others to know there was an accepted answer. the "Item Status Changed" event

edit flag offensive delete link more


Thanks for the info.

What I want to do is:

If I choose an entry from the value list, execute a block of code, but if I type a string into the combobox that does not match an entry in the value list, execute a different block of code. The "Text modified" event would work but it would cycle the code for every character change.

As as side-note: I have not been able to find info re. the "Item Status Changed" event. What is defined as the "status"?

Any info would be appreciated.

hvankampen gravatar imagehvankampen ( 2018-06-05 01:57:10 +0100 )edit

Because of space will add edit in answer.

Ratslinger gravatar imageRatslinger ( 2018-06-05 04:02:28 +0100 )edit

Thank you. This is the info I needed.

hvankampen gravatar imagehvankampen ( 2018-06-05 23:26:49 +0100 )edit

You are quite welcome. Keep in mind that you will probably get more appropriate answers if you describe what you are trying to do rather than to ask how something works.

Ratslinger gravatar imageRatslinger ( 2018-06-05 23:34:58 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-06-04 05:42:57 +0100

Seen: 152 times

Last updated: Jun 05 '18