Results 1 to 7 of 7
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    key binding code (Word 2002 /XP SP3)

    Hello

    I am using the below code using Keybinding.

    Im finding that my code is not assigning the shortcut keys <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

    any ideas?
    diana


    'shortcut keys to call Save and SaveAs.
    'When Word opens, the DM Word template DMIntergration.dot Hummingbird
    'code overwrites the shortcut keys assigned to the code in Normal.dot
    'This code reassigns the keys back to the code in Normal.dot

    Dim aKey As KeyBinding
    CustomizationContext = NormalTemplate

    'from Hummingbird Save & SaveAs remove all the shortcut keys
    For Each aKey In _
    KeysBoundTo(KeyCategory:=wdKeyCategoryMacro, _
    Command:="Project.Main.HumSave")
    aKey.Disable
    Next aKey

    For Each aKey In _
    KeysBoundTo(KeyCategory:=wdKeyCategoryMacro, _
    Command:="Project.Main.HumSaveAs")
    aKey.Disable
    Next aKey

    'reassign the shortcut keys to Corrs code
    CustomizationContext = NormalTemplate
    'to File, Save
    KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyS, wdKeyControl), KeyCategory:= _
    wdKeyCategoryMacro, Command:="CORRSUI.FileSave.Main"
    CustomizationContext = NormalTemplate
    KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyF12, wdKeyShift), KeyCategory:= _
    wdKeyCategoryMacro, Command:="CORRSUI.FileSave.Main"
    CustomizationContext = NormalTemplate
    KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyF2, wdKeyShift, wdKeyAlt), _
    KeyCategory:=wdKeyCategoryMacro, Command:="CORRSUI.FileSave.Main"

    'to File, SaveAs
    CustomizationContext = NormalTemplate
    KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyF12), KeyCategory:= _
    wdKeyCategoryMacro, Command:="CORRSUI.FileSaveAs.Main"

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: key binding code (Word 2002 /XP SP3)

    Is it a problem with the code, or with the sequence of execution at load? In other words, if you already have Word fully loaded and settled down ready to work, and then you run your code, does it work then?

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: key binding code (Word 2002 /XP SP3)

    My code is in a template file called CorrsLib.dot. when Word opens up CorrsLib.dot set the Word environment to our standards.

    When Word opens it loads the global templates...(although Im not sure in which order they get loaded? i thought it was alphabetical)

    Global templates and add-ins:
    ...
    CorrsLib.dot
    ....
    DMIntegration.dot.

    Someone recommended to create a new template and name it "ZZZname.dot", so this is the last template loaded & then run my keybinding code, so its the last thing run on Word open. However I was unsure how to do this?

    I dont think theres an event to do with "Application Open". And I don't think an "AutoOpen" module in my "ZZZname.dot" template would work? because the ZZZname.dot is really 'opened"?

    any ideas?

    diana <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

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

    Re: key binding code (Word 2002 /XP SP3)

    The Document_Open event procedure doesn't fire in an add-in (global template), but if there is a macro named AutoOpen in a standard module, it will be run when Word statrs (and loads the add-in).

  5. #5
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: key binding code (Word 2002 /XP SP3)

    >> but if there is a macro named AutoOpen in a standard module, it will be run when Word statrs (and loads the add-in).

    Now I'm confused Hans. I thought you needed a Sub Main in a module called AutoExec to run code when Word starts... <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

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

    Re: key binding code (Word 2002 /XP SP3)

    Sub Main is a relic of very long ago, when each module had to contain a Sub Main, and the module name was used as the name of the macro. All other procedures in the module were merely auxiliary.

    Nowadays (since Office 97 at least, perhaps longer), a module can contain many macros, each with their own name (which should not coincide with the name of a module).

    If you put a macro named AutoExec in a standard module in your Normal.dot, it will be executed when Word starts.
    In global templates = add-ins, a macro AutoOpen will be run when the template is opened, i.e. when Word starts.

  7. #7
    4 Star Lounger
    Join Date
    Dec 2003
    Location
    Zoetermeer, Zuid-Holland, Netherlands
    Posts
    559
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: key binding code (Word 2002 /XP SP3)

    Thanks for clarification!

Posting Permissions

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