Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    853
    Thanks
    0
    Thanked 9 Times in 8 Posts

    Cool Repurpose FileNew for Word 2010

    I want to repurpose the FileNew command in Word 2010. In Word 2007, I used the following code in the RibbonXML:

    <commands>
    <command
    idMso="FileNew"
    onAction="FileNew_Repurpose"/>
    </commands>

    My custom macro, FileNew_Repurpose, fired as expected when FileNew was clicked. In Word 2010, there's no reaction. Does 2010 require something different to repurpose a Command?

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,432
    Thanks
    3
    Thanked 125 Times in 118 Posts
    Well that is interesting. I didn't know you could repurpose a command by editing the ribbon.

    In the older versions of Word you simply named a macro with the right built-in command name. This appears to still work in Word 2010. As an example if you name a macro 'FileNewDefault' then this macro will run if the user presses Ctrl-N in Word 2010 and this doesn't require any ribbon customisation.

    Another possibility is to verify that you don't have version specific RibbonX files loaded. If there is a customUI14.xml file then that will be Word 2010 specific whilst the customUI.xml will work for both versions only if the other file is not also present.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,870
    Thanks
    0
    Thanked 78 Times in 74 Posts
    How did you declare the FileNew_Repurpose callback? If your declaration doesn't match the expected callback, it won't work. (If you are using the CustomUI editor, it has a button to generate the callback stubs for you). In your case it should be:
    Code:
    Sub FileNew_Repurpose(control As IRibbonControl, ByRef cancelDefault)
    ' your code here
    End Sub
    Last edited by rory; 2011-02-14 at 07:14. Reason: add callback
    Regards,
    Rory
    Microsoft MVP - Excel.

  5. #4
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    853
    Thanks
    0
    Thanked 9 Times in 8 Posts
    FileNew is the only command that is "ignored". If I substitute FileExit or FileOpen or another command (Bold, etc.) my FileNew_Repurpose code fires as expected. FileNew appears to be the lone holdout.

    I'm using the Custom UI Editor to create/place RibbonX code in Word Startup templates. There are no other RibbonX files loaded.

  6. #5
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    853
    Thanks
    0
    Thanked 9 Times in 8 Posts
    That's exactly the callback I'm using. As I said to Andrew, if I substitute FileExit, for example, in the xml code, my macro fires as expected.

  7. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,870
    Thanks
    0
    Thanked 78 Times in 74 Posts
    I don't have 2010 here to test, so will have to take a look when I get home.
    Regards,
    Rory
    Microsoft MVP - Excel.

  8. #7
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,432
    Thanks
    3
    Thanked 125 Times in 118 Posts
    Do you know under which conditions the built-in 'FileNew' command is run? The 'FileNewDefault' appears to create a new document based on Normal whereas 'FileNew' appears to be what you see when you go to the Backstage (Office Button) and click New. Perhaps you could try some of the other FileNew variants...
    FileNew
    FileNewBlankDocument
    FileNewBlogPost
    FileNewDefault
    FileNewDialogClassic
    FileNewWebPage
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  9. #8
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,870
    Thanks
    0
    Thanked 78 Times in 74 Posts
    As far as I can tell from MSDN, in 2010 Backstage view the File-New control is actually a tab, not a control per se, so it has no onAction property for you to intercept. I think you would have to either repurpose (or alter) its controls, or hide it and implement your own button. See this page for info.
    Last edited by Gary Frieder; 2011-02-20 at 23:43. Reason: Make helpful link more visually prominent
    Regards,
    Rory
    Microsoft MVP - Excel.

  10. #9
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    853
    Thanks
    0
    Thanked 9 Times in 8 Posts
    In Word 2007, FileNew runs when you choose File>New from the Office button. We want to repurpose FileNew specifically to avoid the Backstage default with the ability to go to the Internet to select from the hundreds of templates that are available there. We want to display the classic FileNew dialog box, ready to choose a template from the default templates folder.

    I tried substituting FileNewDefault for FileNew in my xml code, and I got the results I expected. FileNew seems to be the lone holdout.

    Richard

  11. #10
    3 Star Lounger
    Join Date
    Jan 2010
    Location
    Chichester, UK
    Posts
    398
    Thanks
    1
    Thanked 10 Times in 9 Posts
    If this helps, you can invoke the 'old' File New dialog by adding the New Document or Template' command to your QAT.

    Or you can edit the Keyboard Shortcuts by selecting FileNewDialog and assigning it Ctrl+N (normally Ctrl+N is assigned to FileNewDefault).

  12. #11
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,432
    Thanks
    3
    Thanked 125 Times in 118 Posts
    Have you tried the command FileNewDialogClassic? This is supposed to be the older style dialog.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  13. #12
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    853
    Thanks
    0
    Thanked 9 Times in 8 Posts
    Thanks, Rory. Your post doesn't display the link that I think you were adding. Would you please trying adding it again? I think it would be useful.
    Thanks,
    Richard

  14. #13
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,870
    Thanks
    0
    Thanked 78 Times in 74 Posts
    That does link to the page I meant to - can i ask why you think otherwise?
    Regards,
    Rory
    Microsoft MVP - Excel.

  15. #14
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 27 Times in 26 Posts
    Rory,

    Thanks for that really useful link. I have to admit I didn't see it the first time 'round - hyperlinks could use to be a more contrasting color on this new version of the site. I've bolded the link in your post so others won't miss it.

    Gary

  16. #15
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    853
    Thanks
    0
    Thanked 9 Times in 8 Posts
    I didn't see any link at all. Gary has remedied that.

Page 1 of 2 12 LastLast

Posting Permissions

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