Why do some of my macros in Word run directly from VBA View Macros list but not from keyboard shortcut? RRS feed

  • Question

  • I am running Word 2010 on my Windows 7 computer.  With many of my macros I can successfully run them using keyboard shortcuts I have assigned them, but with others, although I can run them from the View Macros command (Alt-F8) I can't run them using an assigned keyboard macro.

    For example, I created a simple macro designed to select the text from the insertion point to the end of the paragraph, but not including the paragraph mark:

    Sub Select_to_End_of_Pagagraph()
        Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend
        Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    End Sub

    I can run it using the Alt-F8 command and clicking on that macro name, but although I assigned it to Ctrl+S,E it will not run.  The fact that the keyboard shortcut begins with Ctrl+S doesn't appear to be an impediment, since I have another macro that works fine from its keyboard shortcut of Ctrl+S,H.  Assigning this macro to another keyboard shortcut Ctrl+L,L didn't work either.  When I was using Word 95 and WordBasic I had no such problems with keyboard shortcuts.

    I would appreciate any help on this.

    Saturday, July 27, 2013 9:55 PM

All replies

  • This undoubtedly relates to the fact that these are built-in keyboard assignments, with CTRL+S being especially important as the Save command. Assigning to combinations that include CTRL+S will default to the FileSave command and frankly I wouldn't mess with this. Dual key assignments e.g. Ctrl S,H and Ctrl S,E only seem to work if the underlying CTRL+S is unassigned, or the CTRL+S action operates before you can operate the additional key.

    Use ALT+L instead which is unassigned by default.

    As for the macro, I think I would suggest

    Dim orng As Range
    Set orng = Selection.Range
    orng.End = orng.Paragraphs(1).Range.End - 1

    Graham Mayor - Word MVP

    Sunday, July 28, 2013 6:36 AM