This is my macro code
Sub KeyPressed(oEvent as Object)
Dim oSheet, oForm, oCombox, oCombobox as Object
Dim oControl, oController, oControlView as object
Dim lPos as Long
Dim sItem, sName as String
Dim iItems as Integer
Dim anything as variant
Dim nomItem As Long
Dim oListBox as object
Dim x as integer
Dim bFound as Boolean
Dim oView, oCell as Object
Dim Indice, nCount as Long
Dim oDoc, oField, oDocView as object
oDoc = ThisComponent
If oEvent.KeyCode = com.sun.star.awt.Key.RETURN Then
iItems = oEvent.Source.ItemCount
sItem = oEvent.Source.Text
Transparencia = True
x = 0
bFound = false
While not bFound and x < iItems
If oEvent.Source.getItem(x) = sItem Then
'Print “Entered item IS in list at position —> " & x + 4
oSheet = ThisComponent.Sheets.getByName(“Cobranca”)
oCell = oSheet.getCellByPosition(1, x+3)
ThisComponent.getCurrentController().Select(oCell)
CordeFundo = rgb(255,255,0)
Transparencia = False
oCell.CellBackColor = CordeFundo
oCell.IsCellBackgroundTransparent = Transparencia
oController = ThisComponent.getCurrentController()
oForm = oSheet.getDrawpage().getForms().getByIndex(0)
oControl = oForm.getByName(“cbCobranca”)
oControlView = oController.getControl(oControl)
oControlView.Text=""
oControlView.setFocus()
bFound = True
Else
x = x + 1
End if
Wend
ElseIf oEvent.KeyCode < 256 or (oEvent.KeyCode > 265 and oEvent.KeyCode<> 1024_
and oEvent.KeyCode<> 1025 and oEvent.KeyCode<> 1280 and oEvent.KeyCode<> 1283) Then
oEvent.Source.Text=”"
End If
End Sub
.
.
.
The bold one should focus the combo box