Sub KeyPressed(oEvent as Object)
Dim oSheet, oForm, oCombox, oCombobox, oCursor 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 x as integer
Dim bFound as Boolean
Dim oView, oCell as Object
Dim Indice, nCount as Long
Dim oDoc, oField, oDocView as object
Dim oButtom, oFormmodel, oFormController as Object
Dim oListbox, oListboxControl as Object
oDoc = ThisComponent
If oEvent.KeyCode = com.sun.star.awt.Key.RETURN Then
iItems = oEvent.Source.ItemCount
sItem = oEvent.Source.Text
x = 0
bFound = false
While not bFound and x < iItems
If oEvent.Source.getItem(x) = sItem Then
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.setFocus()
oControlView.Text=""
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
.
.
.
Para quem estiver interessado esse é a macro que possibilita procurar o número na caixa de combinação, pintar de amarelo a célular e focar novamente na caixa de combinação (cbCobranca)
.
.
A parte em negrito é que faz o foco voltar a caixa de combinação, mas o comando não leva até ela…muito estranho isso::::: foca, mas não vai até ela.