#1
|
||||
|
||||
Addin-specific keyboard shortcuts refuse to turn off
Hi folks. I have an .dotm add-in containing about 20 macros. It also contains two other macros that let my users enable or disable a set of keyboard shortcuts for these macros as needed -- that is, only for specific documents. (The shortcuts commandeer some commonly used built-in key combinations, so I want them enabled only when a user explicitly allows it.) I've done this successfully before. But on this file, for some reason, merely loading the add-in enables the shortcuts -- in all documents.
I've confirmed via the Customize Keyboard dialog that these shortcuts are *not* enabled in the .dotm itself, but I've also explicitly disabled them via code just in case. I've tried unloading all other add-ins and had Word rebuild the Normal template to verify they're not hiding there either. No luck. I'm sure they're enabled in the add-in. (They go away if I unload it.) What could be causing this?? There are no automacros in the file, and the shortcut-enabling macro (see below) isn't called by any other macro. All shortcuts are set with the Customization Context shown, the active document. (not Normal or ThisDoc). Sub KM1(mac, k1) CustomizationContext = ActiveDocument KeyBindings.Add KeyCode:=BuildKeyCode(k1), _ KeyCategory:=wdKeyCategoryMacro, Command:=mac End Sub Sub KM2(mac, k1, k2) CustomizationContext = ActiveDocument KeyBindings.Add KeyCode:=BuildKeyCode(k1, k2), _ KeyCategory:=wdKeyCategoryMacro, Command:=mac End Sub Sub EnableShortcuts KM1 "LengthenLine", wdKeyF4 KM1 "ShortenLine", wdKeyF5 [...and so on...] KM2 "SelectPrevPair", wdKeyControl, wdKeyF4 KM2 "SelectNextPair", wdKeyControl, wdKeyF5 [...and so on...] Thanks in advance for any clues at all. Mark |
#2
|
||||
|
||||
There's nothing apparent from what you've posted that you ever clear or disable the new keybindings. In any event, once they're set, they're available to all documents. If you wanted to limit their scope to documents based on a particular template, I believe you'd need to add/enable & clear/disable them via WindowActivate & WindowDeactivate events.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
||||
|
||||
Cross-posted at: http://answers.microsoft.com/en-us/o...e-82212d91ee9b
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
||||
|
||||
Quote:
I'm certain it's possible to limit the scope of a shortcut to a single document with the CustomizationContext property; I do it often in other add-ins, and there are examples in the documentation for it (and I did it just now with a simple add-in to prove I'm not hallucinating...). I'm tempted to pour all the code from the this add-in into an emptied-out version of one where it works.... I was just hoping for a revelation that would save me from that. |
#5
|
|||
|
|||
From Microsoft Answers thread...
Quote:
Quote:
Otherwise, you must have an Auto-procedure that is running your installation code. It has been a long time (i.e. years ago in menu versions) since I did anything with keybindings through vba. It is my recollection that the customization context did not work as I expected it to. I would recommend a google search for "vba keybinding customizationcontext." Here is one exchange that looks promising: http://www.experts-exchange.com/Soft..._27858835.html |
#6
|
||||
|
||||
No, as I said in the original post, I tried unloading all the other add-ins and regenerating normal.dotm. They're definitely hiding in (and somehow returning zombie-like to and after being deleted from) the suspect add-in.
|
Tags |
code, disable, keyboard shortcuts |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to create keyboard shortcuts for a specific font | ravl13 | Word | 2 | 04-07-2013 05:45 AM |
Is there a way to list all keyboard shortcuts? | Jennifer Murphy | Word | 1 | 08-02-2012 01:48 PM |
Can I turn off keyboard shortcuts? | martinlest | Outlook | 1 | 06-10-2012 09:49 PM |
Impermanent keyboard shortcuts | Subligaria | Word | 2 | 11-01-2011 12:41 PM |
Customizing Keyboard Shortcuts | zextrot | Outlook | 0 | 11-11-2010 01:43 PM |