From: Christopher Rath Date: Mar 5 1998, 4:00 am Subject: ANNOUCE: VBAcs, VBA macros to enable Emacs shortcut keys in MSWord To: comp.lang.basic.visual.misc Here is a second release ofVBAcswith more complete instructions on how to make use ofVBAcs. Thanks to "Word97 Annoyances", by Woody Leonhard, Lee Hudspeth & T.J. Lee; the book that showed me how to do this. -8><--8><--8><--8><--8><--8><--8><--8><--8><--8><--8><--8><--8><- 'VBAcs-VBAto createEmacsshort-cutkeysin MS Word. 'Author: Christopher Rath 'Date: 2 Mar., 1998 'Version: 0.2 'Copyright (c) 1998 Christopher Rath 'Distributed under Perl's "Artistic License" ''''' 'Thanks to "Word97 Annoyances", by Woody Leonhard, Lee Hudspeth & 'T.J. Lee; the book that showed me how to do this. ' 'This is a first cut at suchmacros. They are not ideal; this version 'is really a "proof of concept" not a finished product. ' 'InstallingVBAcs: ' Basically, this means: place thesemacrosin a Production module ' within a document that resides within your Startup folder. ' Specifically, this means: ' ' 1. StartMSWord. ' 2. If you have a template called "MyMacros.dot" in your startup ' folder, open it; if you don't have one, then via the File->New ' menu create a new template and perform a File->Save As... to ' create a "MyMacros.dot" file in your startup folder. ' 3. Menu: Tools->Macro->Visual Basic Editor (Alt-F11) ' 4. Use the Project Explorer to nagivate to "MyMacros.dot"'s ' Production modules; if no Production module exists, then ' perform an Insert->Module and name the module "Production". ' 5. Cut and paste theVBAcscode into the "code" window. ' 6. Press and select "RemapKeys" to run the code. ' 7. Close the VB Editor window and save the template. ' 'Change Log: ' v0.1 - First public release. ' v0.2 - Fixed ClearToEndOfLine() so it doesn't delete the paragraph marker ' - Added full install instructions ''''' Public Sub TypeEn() 'To be assigned to "[ALT]-". Selection.TypeText Chr$(150) End Sub Public Sub TypeEm() 'To be assigned to "[ALT][SHIFT]-". Selection.TypeText Chr$(151) End Sub Public Sub ClearToEndOfLine() 'To be assigned to "[CTRL]K". Selection.EndKey Unit:=wdLine, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.Delete Unit:=wdCharacter, Count:=1 End Sub Public Sub RemapKeys() 'This Sub remaps my keyboard, a laEmacs. CustomizationContext = NormalTemplate KeyBindings.Add KeyCategory:=wdKeyCategoryMacro, Command:="TypeEn", KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyHyphen) '"[A]-" KeyBindings.Add KeyCategory:=wdKeyCategoryMacro, Command:="TypeEm", KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyShift, wdKeyHyphen) '"[A][SHIFT]-" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyP), KeyCategory:=wdKeyCategoryCommand, Command:="LineUp" '"[C}P" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyN), KeyCategory:=wdKeyCategoryCommand, Command:="LineDown" '"[C]N" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyE), KeyCategory:=wdKeyCategoryCommand, Command:="EndOfLine" '"[C]E" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyA), KeyCategory:=wdKeyCategoryCommand, Command:="StartOfLine" '"[C]A" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyF), KeyCategory:=wdKeyCategoryCommand, Command:="CharRight" '"[C]F" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyB), KeyCategory:=wdKeyCategoryCommand, Command:="CharLeft" '"[C]B" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyS), KeyCategory:=wdKeyCategoryCommand, Command:="EditFind" '"[C]S" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyW), KeyCategory:=wdKeyCategoryCommand, Command:="EditCut" '"[C]W" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyY), KeyCategory:=wdKeyCategoryCommand, Command:="EditPaste" '"[C]Y" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyW), KeyCategory:=wdKeyCategoryCommand, Command:="EditCopy" '"[A]W" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyShift, wdKeyControl, wdKeyHyphen), KeyCategory:=wdKeyCategoryCommand, Command:="EditUndo" '"[S][C]-" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyD), KeyCategory:=wdKeyCategoryCommand, Command:="DeleteWord" '"[A]D" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyShift, wdKeyAlt, wdKeyComma), KeyCategory:=wdKeyCategoryCommand, Command:="StartOfDocument" '"[S][A]<" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyShift, wdKeyAlt, wdKeyPeriod), KeyCategory:=wdKeyCategoryCommand, Command:="EndOfDocument" '"[S][A]>" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyV), KeyCategory:=wdKeyCategoryCommand, Command:="PageDown" '"[C]V" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyV), KeyCategory:=wdKeyCategoryCommand, Command:="PageUp" '"[A]V" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyF), KeyCategory:=wdKeyCategoryCommand, Command:="WordRight" '"[A]F" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyB), KeyCategory:=wdKeyCategoryCommand, Command:="WordLeft" '"[A]B" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyG), KeyCategory:=wdKeyCategoryCommand, Command:="Cancel" '"[C]G" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyAlt, wdKeyBackspace), KeyCategory:=wdKeyCategoryCommand, Command:="DeleteBackWord" '"[A][BS]" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyD), KeyCategory:=wdKeyCategoryCommand, Command:="EditClear" '"[C]D" KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyControl, wdKeyK), KeyCategory:=wdKeyCategoryCommand, Command:="ClearToEndOfLine" '"[C]K" End Sub -8><--8><--8><--8><--8><--8><--8><--8><--8><--8><--8><--8><--8><- Sincerely, Christopher === Christopher Rath === cr...@nortel.ca === (613) 765-3141 === Northern Telecom Ltd. | Box 3511, Station `C' | ``Hydrogen is a colourless, odourless Ottawa, ON K1Y 4H7 | gas which, given enough time, turns FAX: (613) 763-4101 | into people.'' --- Henry Hiebert