Execute find focuse via script or dispatch

I am wondering if I can execute a command such as vnd.sun.star.findbar:FocusToFindbar in a macro.

I am working on menu support for OOO Development Tools (OooDev).

Getting menus is something like this.

>>> menu = Menus()[Service.CALC]["edit"]
>>> itm = menu.items[13]
>>> itm.command
'.uno:SearchDialog'
>>> itm.execute() # dispatches the command.

>>> itm = menu.items[12]
>>> itm.command
'vnd.sun.star.findbar:FocusToFindbar'
>>> itm.execute() # not currently possible.

This is the command from Tools → customize → Menus for find.

Label: Find
Command: vnd.sun.star.findbar:FocusToFindbar
Tooltip: Find (Ctrl+F)

I can execute macros from OooDev but it expects format in the following style:

vnd.sun.star.script:myLibrary.myModule.myMacro?language=Basic&location=application

This is done in the usual way (see also here):

Sub GotoFindbar
  Dim oDisp as Object
  oDisp = createUnoService("com.sun.star.frame.DispatchHelper")
  oDisp.executeDispatch(ThisComponent.CurrentController.Frame, "vnd.sun.star.findbar:FocusToFindbar", "", 0, Array())
End Sub

Excellent. This works great.
Also other formats work.

Sub OpenExtensionDialog
  Dim oDisp as Object
  oDisp = createUnoService("com.sun.star.frame.DispatchHelper")
  oDisp.executeDispatch(ThisComponent.CurrentController.Frame, "service:com.sun.star.deployment.ui.PackageManagerDialog", "", 0, Array())
End Sub
2 Likes