Search notes:

Office Object Model: Word - KeyBindings

add

With the add method, a new keyboard shortcut key can be added to a document:
option explicit

sub main() ' {

    application.customizationContext = thisDocument

    application.keyBindings.add keyCode := buildKeyCode(wdKeyF8                            ), keyCategory := wdKeyCategoryCommand, command := "f8WasPressed"
    application.keyBindings.add keyCode := buildKeyCode(wdKeyF8, wdKeyControl              ), keyCategory := wdKeyCategoryCommand, command := "ctrlF8WasPressed"
    application.keyBindings.add keyCode := buildKeyCode(wdKeyF8, wdKeyShift                ), keyCategory := wdKeyCategoryCommand, command := "shiftF8WasPressed"
    application.keyBindings.add keyCode := buildKeyCode(wdKeyF8, wdKeyControl, wdKeyShift  ), keyCategory := wdKeyCategoryCommand, command := "ctrlShiftF8wasPressed"

end sub ' }

sub f8WasPressed() ' {
    debug.print "F8 was pressed"
end sub ' }

sub ctrlF8WasPressed() ' {
    debug.print "Ctrl+F8 was pressed"
end sub ' }

sub shiftF8WasPressed() ' {
    debug.print "Shift+F8 was pressed"
end sub ' }

sub ctrlShiftF8WasPressed() ' {
    debug.print "Ctrl+Shift+F8 was pressed"
end sub ' }
Github repository about-MS-Office-object-model, path: /Word/KeyBindings/add.bas

See also

Word Object Model

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1742060948, '3.140.184.203', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/Office/Word/Object-Model/KeyBindings/index(71): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78