Hello Everyone,
I’ve read here about a method that used a string sCommand to reach to a module, probably got with record macro button. Then I wrote the macro below, trying to assign the Save Command to Ctrl+S. After runnig the macro, I got an error “BASIC runtime error. Sub-procedure or function procedure not defined.”, the setKeyEvent highlighted. Any Ideas?
Sub SaveKeyWriter
sCommand = "vnd.sun.star.script:Standard.Module2.MainSave?language=Basic&location=document"
oModuleCfgMgrSupplier = createUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")
oModuleCfgMgr = oModuleCfgMgrSupplier.getUIConfigurationManager("com.sun.star.text.TextDocument")
oWriterAccelCfgmgr = oModuleCfgMgr.getShortCutManager()
Dim aKeyEvent as new com.sun.star.awt.KeyEvent
aKeyEvent.Modifiers = com.sun.star.awt.KeyModifier.MOD1
aKeyEvent.KeyCode = com.sun.star.awt.Key.S
setKeyEvent(aKeyEvent,sCommand)
msgbox oWriterAccelCfgmgr.getCommandByKeyEvent(aKeyEvent)
End Sub
sub MainSave
dim document as object
dim dispatcher as object
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, ".uno:Save", "", 0, Array())
end sub