Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-14-2014, 09:21 PM
mark99k's Avatar
mark99k mark99k is offline Addin-specific keyboard shortcuts refuse to turn off Windows 7 32bit Addin-specific keyboard shortcuts refuse to turn off Office 2010 32bit
Novice
Addin-specific keyboard shortcuts refuse to turn off
 
Join Date: Oct 2012
Location: California USA
Posts: 20
mark99k is on a distinguished road
Unhappy 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
Reply With Quote
  #2  
Old 07-14-2014, 10:00 PM
macropod's Avatar
macropod macropod is offline Addin-specific keyboard shortcuts refuse to turn off Windows 7 32bit Addin-specific keyboard shortcuts refuse to turn off Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 07-14-2014, 10:06 PM
macropod's Avatar
macropod macropod is offline Addin-specific keyboard shortcuts refuse to turn off Windows 7 32bit Addin-specific keyboard shortcuts refuse to turn off Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #4  
Old 07-14-2014, 10:47 PM
mark99k's Avatar
mark99k mark99k is offline Addin-specific keyboard shortcuts refuse to turn off Windows 7 32bit Addin-specific keyboard shortcuts refuse to turn off Office 2010 32bit
Novice
Addin-specific keyboard shortcuts refuse to turn off
 
Join Date: Oct 2012
Location: California USA
Posts: 20
mark99k is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
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.
Hi Paul. I actually have tried both disabling and clearing but it made no difference, and I've since read in the documentation for the Keybinding.Disable method, "You don't need to remove or rebind a KeyBinding object before adding it elsewhere."

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.
Reply With Quote
  #5  
Old 07-15-2014, 05:06 AM
Charles Kenyon Charles Kenyon is offline Addin-specific keyboard shortcuts refuse to turn off Windows 7 64bit Addin-specific keyboard shortcuts refuse to turn off Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,083
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

From Microsoft Answers thread...
Quote:
I have not reviewed your code. Sorry, it is not my strong suit.

However, if the keyboard shortcuts become active when the Add-In template is loaded, they are in the template. Apparently your ran your code at some time when the active document was the template.

You can use Chris Woodman's old shortcut organizer to find them and get rid of them. Open your Add-In template as an open file (not loaded, not the attached template, the active document). Load the Shortcut Organizer as an Add-In and use it.
keyboard shortcuts organizer
response there
Quote:

Hi Charles. This looked quite promising (had to edit the code to see .dotm's). It showed the shortcuts I'd assumed I'd removed as being present. But after resetting them with this tool, then saving, then reloading the add-in, they're back! Grrrr
With your Add-In not loaded are the keyboard shortuts active? You may have loaded them in other Add-Ins or even in your normal.dotm. The shortcut organizer should be able to ferret them out.


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
Reply With Quote
  #6  
Old 07-15-2014, 11:22 AM
mark99k's Avatar
mark99k mark99k is offline Addin-specific keyboard shortcuts refuse to turn off Windows 7 32bit Addin-specific keyboard shortcuts refuse to turn off Office 2010 32bit
Novice
Addin-specific keyboard shortcuts refuse to turn off
 
Join Date: Oct 2012
Location: California USA
Posts: 20
mark99k is on a distinguished road
Default

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.
Reply With Quote
Reply

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
Addin-specific keyboard shortcuts refuse to turn off 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:10 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft