# Return focus to calc sheet [closed]

I use the following code to see if the currently active cell is in edit mode (i.e. has an insertion point), and if so "click" the Accept button so that we can modify the cell:

' Check to see if we are in edit mode (with active cursor in the cell)
oAC = ThisComponent.CurrentController.Frame.ComponentWindow.accessibleContext
oACToolbar = oAC.getAccessibleChild(1).accessibleContext
oACSumCancel = oACToolbar.getAccessibleChild(3)
sName = oACSumCancel.AccessibleName
If sName <> "Sum" Then
' we are in edit mode, attempt to get out of it or else we can't modify the cell
oACFunctionAccept = oACToolbar.getAccessibleChild(4)
oACFunctionAccept.grabFocus
oACFunctionAccept.doAccessibleAction(0)
End If


But when control is returned to the user, the "focus" is still up in the toolbar. Can someone tell me how to get the focus back on the spreadsheet? I tried a selection, but the focus seems to be a different thing than the selection. And if the focus is up in the toolbar, when the user types the arrow keys or Enter, the results aren't what he expects, since they are acting up the toolbar. So how do I set focus back on the spreadsheet?

edit retag reopen merge delete