Results 1 to 15 of 15
  1. #1
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Keybindings not working (2002)

    I've got a .dot file which contains a macro to set some keybindings like this:

    Public Sub DoBindKeys()
    CustomizationContext = ThisDocument
    KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyA, wdKeyAlt), KeyCategory:= _
    wdKeyCategoryMacro, Command:="Module1.Play"
    KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyP, wdKeyAlt), KeyCategory:= _
    wdKeyCategoryMacro, Command:="Module1.Pause"
    ...
    ThisDocument.Save
    End sub

    For some reason, when I load the .dot file as an addin and try to use the bindings, none of them seem to do anything (the macros are definitely there). I'm almost certain this used to work. Any ideas?

    Dan

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Keybindings not working (2002)

    The DoBindKeys macro will not be run automatically. You must call it from the Document_Open event procedure in the ThisDocument module of your add-in (global template):

    Private Sub Document_Open()
    Call DoBindKeys
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keybindings not working (2002)

    But what if I have run it prior to loading the addin. In other words, I've saved the keybindings in the dot file and then distributed it.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Keybindings not working (2002)

    Yes, the keybindings should work then - I just tested it.

    Try the following:
    - Select Tools | Customize...
    - Click Keyboard...
    - Click in the 'Press new shortcut key' box.
    - Press Alt+A or Alt+P.
    What is displayed after 'Currently assigned to'?

  5. #5
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keybindings not working (2002)

    Nothing.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Keybindings not working (2002)

    Try running DoBindKeys again to see if the keybindings "stick". If not, you could call it in the Document_Open event procedure to make sure the keybindings get set up each time (even though this shouldn't be necessary).

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Keybindings not working (2002)

    Something else: are you sure that macro security has been set to Medium (not High), or that 'Trust all installed add-ins and templates' has been ticked in the Trusted Sources tab of Tools | Macro | Security?

  8. #8
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keybindings not working (2002)

    Yes, all is well there. And when I run DoBindKeys, the keybindings still don't show up. I'm going to try rebuilding the template from scratch. Maybe it's corrupted.

  9. #9
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keybindings not working (2002)

    Didn't help.

  10. #10
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keybindings not working (2002)

    More info: when I actually open my .dot file (rather than merely loading it as an addin via the Templates and Addins dialog), then my keybindings work. However, if I then open another document (so that document is active rather than my .dot file), the bindings stop working. I thought that, if my .dot file is loaded as an addin, its bindings should be in effect whether the .dot file is the active doc or not. Again--I've seen this work before.

    Dan

  11. #11
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keybindings not working (2002)

    Even more info: if I *attach* the template to the active document, then the keybinding works on that document. Does that mean that you must attach a template to a document for its keybindings to work on that document? If that's the case, then what's the point of loading a template as opposed to attaching it?

  12. #12
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keybindings not working (2002)

    Here you go Hans....Dan
    Attached Files Attached Files

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Keybindings not working (2002)

    Could you attach a version of your template with only the keybindings (and related code)? There doesn't need to be any text in the template, or any code not related to the keybindings. Zip the template and attach the .zip file.

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Keybindings not working (2002)

    I copied the template from the zip file to my Word startup folder. When I started Word, the Alt+] key inserted some text into the blank document that Word automatically creates when you start it. So the keybinding worked right out of the box.
    If it doesn't work for you, there are several possible explanations:
    - Security is too tight, but you've already ruled that out.
    - The template isn't stored in the right place. Can you verify whether it is actually loaded with Word? (Check Tools | Templates and Add-Ins...)
    - There is a conflict with other add-ins. Try removing all other add-ins temporarily.

  15. #15
    2 Star Lounger
    Join Date
    Sep 2002
    Posts
    180
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Keybindings not working (2002)

    I renamed normal.dot and it started to work. I doubt if it was conflicting shortcuts, as none of the keybindings seemed to work. Probably a corrupted normal.dot. Thanks for your help...Dan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •