• Key Assignment failure (VBA/Word/97 & 2000)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Key Assignment failure (VBA/Word/97 & 2000)

    Author
    Topic
    #390857

    Advice is required to solve a problem I am experiencing with key assignments in MS Word.

    The scenario is a template with a number of macros stored in C:Program FilesMicrosoft OfficeOfficeStartup. These macros are run either from a custom toolbar button or a key assigment. One key assignment (Alt+Z) will sometimes not work and a printout of the key assignments indicates the following against its name “The macro named TEMPLATEPROJECT.NEWMACROS.MACRO1 does not exist.”

    But, open the template and go to the VBE and a single step through the code does work. Also a re-assignment of the keyboard shortcut indicates that it is still assigned (but I know it does not work) and when I rebuilt the template by exporting every module and macro then importing them back into a new document and re-assigning the keyboard shortcut for the macro ((Alt+Z, same as previous) it works initially but will give up without any particular action on the part of the user or me.

    All suggestions will be greatly appreciated as I am perplexed as to why it should happen.

    Are there any differences between the Startup folder usage for WinNT/Word 97 and Win2000/Word 2000 that I am missing?

    Thanks, Leigh

    Viewing 1 reply thread
    Author
    Replies
    • #696086

      i’m not sure, but you could try to recreate the template with a different (and unique) project name.

    • #696317

      I can’t remember the syntax for key assignments. Does it force you to refer to a particular template? If not, it probably relies on the CustomizationContext setting for where to store it. If you look that up in the online help, it might, uh, help. grin Here’s something from the past that shows sort of what I mean:[indent]


      Subject: Re: stop tab from creating rows (2000) [#210057]
      Poster: StuartR
      Posted on: 02-Jan-03 22:00

      Using Klaus Linke’s code from post 114359 we could create a pair of Macros like.

      Public Sub TabToNextFormField() 
          Selection.GoTo What:=wdGoToField, Which:=wdGoToNext 
      End Sub 
       
      Sub SetKeyBindings() 
          CustomizationContext = NormalTemplate
          KeyBindings.Add KeyCategory:=wdKeyCategoryMacro, _ 
              Command:="TabToNextFormField", _ 
              KeyCode:=wdKeyTab 
      End Sub

      Execute SetKeyBindings once to assign the Macro to the Tab key
      You may need to change the NormalTemplate in the second one to point to somewhere different (e.g. ActiveDocument.Template)
      You could modify the TabToFormField macro so that it changes its behaviour depending on whether the selection is in a table.


      [/indent]Hope this helps.

      • #696598

        Thanks Pieter and Jefferson for your replies.

        Firstly, something very strange happened before the following steps were taken. A key assignment (the wretched Alt+Z combo) decided to re-assign itself to another of the 17 modules (BTW, there are also 13 userforms!!). I had never had this problem before.

        Now I have looked at both suggestions after printing all the key assignments and deleted all those key assignments in the opened template:

            Tools | Customize... | Keyboard... | Reset all...

        Then, for good measure I renamed the offending module and tested the key assignments in a new document (they didn’t exist, so that was easy!). Nothing untoward so far.

        Next step was to assign new key assignments to each of the relevant modules and test them. For good measure I also recreated the Alt+Z combo and tested all of them. (There were six, three open userforms, three run a macro directly.)

        Lo and behold, Alt+Z is the only one not to work! Bizarre? So I have now taken the precaution of also assigning Alt+C (other end of the scale in case the operating system has a problem at the bottom end of the alphabet) AND given users a toolbar button if all else fails.

        Now for extended testing… throwing it to the real users. WML (Wish Me Luck please)

    Viewing 1 reply thread
    Reply To: Key Assignment failure (VBA/Word/97 & 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: