How can I write a macro to add a combobox in a sheet?

I want to write a macro in Calc to insert a combobox when i click in any cell in column C and when i click in other cells in column C the combobox move with cursor to that cell and when click in other column the combobox disapears. Please help me. thanks

The Data validity feature (applied for the cells in the column C) is not enough for you? It not require any macro.

I suppose it: if you want to fill the cells based on the selection from the combobox…

Thank you. I didn’t know this feature. But what I asked is actually part of a bigger project which needs the combobox. In fact the list itself is variable (not some fixed items) and the items come from another macro.

Hello,

This should be of some help → Manipulating an Image Button in a Calc Sheet

The button component will need to be replaced with your combo box. See com::sun::star::form::component Module Reference

Thank you. it’s exactly what i was searching for.

“The Data validity feature (applied for the cells in the column C) is not enough for you? It not require any macro.”

“But what I asked is actually part of a bigger project which needs the combobox. In fact the list itself is variable (not some fixed items) and the items come from another macro.”

You can use the option “Cell Range” as a source of the Data Validity dropdown list. And you can a dinamically change the cell content of the source range by cell functions - or by your other macros.

Yes, it works perfectly and very simple solution. thank you very much.