Macro to open a specific menu

I have searched high and low for information on the menubar. I have found a lot of interesting things. What i can’t find should be the simplest of all. How do you open a menu from the menubar with a macro.

I am building a custom toolbar that contains my most used items. There are certain menus or sub menus i would like to add to the toolbar. But i can not find any info on how to do this.

This is really frustrating. I hope someone can help before I’m completely bald.

indeed.

an easy shortcut : Recording a Macro

will give you for example :

document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

dispatcher.executeDispatch(document, ".uno:About", "", 0, Array())
1 Like

Yes I have used record to create some of the toolbar buttons like “merge cells”. However when i try to record just opening a menu like “tools - macro” nothing gets recorded.

sub Popup1stMenu
  fr = ThisComponent.CurrentController.Frame
  lm = fr.LayoutManager
  el = lm.getElement("private:resource/menubar/menubar")
  menu = el.XMenuBar
  id1 = menu.getItemId(0)
  menu1 = menu.getPopupMenu(id1)
  dim rect as new com.sun.star.awt.Rectangle
  menu1.execute(fr.ContainerWindow, rect, com.sun.star.awt.PopupMenuDirection.EXECUTE_DEFAULT)
end sub
2 Likes

com.sun.star.awt.PopupMenuDirection.EXECUTE_DEFAULT)
[/quote]

This line gives an error.

“Object Variable Not Set”

Thank you for the code and any more advice you have.

I’m sorry I didn’t mention earlier and I hope it is not a problem. I am not exactly using Libre Office. I asked the question here because I have learned to build macros mostly from Libre Office forums and documentation. I understand if you don’t wish to help any further but I will try to figure It out from the code you have offered. Thank you.

I am using:

Android
Version 11

AndrOpen Office
Version 5.4.5 / 45642

Apache OpenOffice™
Version 4.1.15

X Window System™
Version 11 Release 7.7

:slight_smile:
Not because I “don’t wish to help any further”, but because I have absolutely zero knowledge about differences stemming from using AndrOpen Office - both it being based on Apache OpenOffice, and being wrapped into something. Sorry.

1 Like

I understand. Thank you

Maybe try to replace this with 0 (assuming only the value is missing in that BASIC). If it is a problem, because Android handles this menues differently I can’t help…

1 Like