none
Word 2010 - Rebind CTRL+N key RRS feed

  • Question

  • Hi Everyone

    I have been asked to look at rebinding the out of box functionality of CTRL+N so that it displays our custom dialog - then users can choose a template they wish to create a document from.  I have tried rebinding through macros and through our Word Addin but cannot seem to get it working properly so I have changed tact.  I am now checking the value of the template name (i,.e. if its normal.dotm) in the new document event.  If it is, the I call our dialog but Im now running into a situation where on a document close event, the document new event gets called again.

    Has anyone done anything like this?  I probably cant see wood for tree's and its a simple solution!  Hope you can help.

    anna


    Anna
    Wednesday, December 21, 2011 12:37 PM

Answers

  • Hi Anna

    Which programming language do you use/prefer? (Basically, what I'm asking is whether VBA macros are acceptable or if you prefer to use a .NET Add-in.)

    You say you've tried rebinding Ctrl+N through macros and it didn't work. Could you please describe in more detail exactly what you tried and how it didn't work?

    From my point of view, you'd have two possibilities. One would be to have a VBA macro that displays the interface you want to use and map Ctrl+N to that. Put this mapping in a template that's in the users' Startup directory and it should be loaded automatically (as an add-in). This approach can only work with VBA.

    The other tack is to repurpose the FileNew command via a Ribbon XML customization and have that callback (whether VBA or .NET) display the interface you want to use.


    Cindy Meister, VSTO/Word MVP
    Wednesday, December 21, 2011 4:13 PM
    Moderator

All replies

  • Hi Anna

    Which programming language do you use/prefer? (Basically, what I'm asking is whether VBA macros are acceptable or if you prefer to use a .NET Add-in.)

    You say you've tried rebinding Ctrl+N through macros and it didn't work. Could you please describe in more detail exactly what you tried and how it didn't work?

    From my point of view, you'd have two possibilities. One would be to have a VBA macro that displays the interface you want to use and map Ctrl+N to that. Put this mapping in a template that's in the users' Startup directory and it should be loaded automatically (as an add-in). This approach can only work with VBA.

    The other tack is to repurpose the FileNew command via a Ribbon XML customization and have that callback (whether VBA or .NET) display the interface you want to use.


    Cindy Meister, VSTO/Word MVP
    Wednesday, December 21, 2011 4:13 PM
    Moderator
  • Hi Cindy,

    Sorry for the late reply.  I prefer to use c#.  I have managed to find a way around this in that when new document event is fired, I check to see what template is attached.  If its normal.dotm - I know that they have performed a ctrl N - because any other time this event is called, it will have one of our templates attached.  I then display the dialog box for the user to choose a template.

    This seems to be fine except that I have noticed - whether this code is in here or not that new document event is being fired twice which I dont understand!  Any ideas to why this would happen?  Im sure I am probably doing something silly.

    Many thanks again for your help

    anna

     


    Anna
    Tuesday, December 27, 2011 8:23 AM
  • Hi Anna

    <<This seems to be fine except that I have noticed - whether this code is in here or not that new document event is being fired twice which I dont understand!  Any ideas to why this would happen? >>

    The first thought that occurs to me is that you're assigning the event handler twice?


    Cindy Meister, VSTO/Word MVP
    Tuesday, December 27, 2011 3:45 PM
    Moderator
  • Hi Cindy

    I have found that a third party addin seems to be causing the problem.  Waiting to hear from them.

    Thanks again for your help.

    anna


    Anna
    Wednesday, December 28, 2011 8:58 AM