Hi,

I need some help to modify the code below for set the shortcut in Calc document.

I try to change the line:

oModuleCfgMgr =_ oModuleCfgMgrSupplier.getUIConfigurationManager("com.sun.star.text.TextDocument" )

to
oModuleCfgMgr =_ oModuleCfgMgrSupplier.getUIConfigurationManager("com.sun.star.table.Spredsheet" )

but get error...

Can you help me?


Many thanks for your help

Bart


Carsten Driesner ha scritto:

here is a little Basic example on how to set accelerators.

REM  *****  BASIC  *****
REM *** Example to set a keyboard shortcut with the new ui configuration API

Sub Main
    REM *** Initialize constants. See IDL file
    REM com.sun.star.awt.KeyEvent
    REM com.sun.star.awt.KeyModifier
    REM com.sun.star.awt.Key
    MODIFIER_SHIFT = 1
    MODIFIER_MOD1  = 2
    MODIFIER_MOD2  = 4
KEY_F10 = 777 REM *** Retrieve the global accelerator configuration manager oGlobalAccelCfgMgr = createUnoService("com.sun.star.ui.GlobalAcceleratorConfiguration")

REM *** Retrieve the module configuration manager from central module configuration manager supplier oModuleCfgMgrSupplier = createUnoService("com.sun.star.ui.ModuleUIConfigurationManagerSupplier")

REM *** Retrieve the module configuration manager with module identifier
    REM *** See com.sun.star.frame.ModuleManager for more information
oModuleCfgMgr = oModuleCfgMgrSupplier.getUIConfigurationManager( "com.sun.star.text.TextDocument" ) REM *** Retrieve the writer accelerator configuration manager
    oWriterAccelCfgmgr = oModuleCfgMgr.getShortCutManager()

    REM *** Define short cut key event for our macro
    Dim aKeyEvent as new com.sun.star.awt.KeyEvent
    aKeyEvent.Modifiers = MODIFIER_SHIFT
    aKeyEvent.KeyCode   = KEY_F10

    REM *** Set our short cut at the Writer accelerator manager
oWriterAccelCfgMgr.setKeyEvent( aKeyEvent, "macro:///Standard.Module1.Test" )
    oWriterAccelCfgMgr.store()
End Sub

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to