locked
Intercept events in word 2010 RRS feed

  • Question

  • Hi

    Is it possible to intercept the File ->print event in word 2010? I would like to do something when user clicks on "Print" under the File menu toolbar and "View" up on the toolbar.

    Many thanks

     

    Wednesday, November 24, 2010 1:00 AM

Answers

  • There are many items in the Backstage view that have not been exposed to Visual Basic.  To intercept that command, you will need to customize the backstage view.

    See http://technet.microsoft.com/en-us/library/ff468686.aspx

    -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "crunchy1821" wrote in message news:a3eb598d-b0b0-47b1-a96c-1ba8ba9696be@communitybridge.codeplex.com...

    I could get the Create button enabled. Thanks for your instruction.

    However, it still does not work, Doug.

    I have a very simple code that I want it to do as follows for testing only

    Sub PrintPreviewAndPrint()
    '
    ' PrintPreviewAndPrint Macro
    '
    '
     msgbox "Hello World"
    End Sub

    But when I went to File -> Print, it did not bring up the Hello World pop-up dialog box. Have I done anything wrong here. please correct me.

    Thank you


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    • Marked as answer by Sally Tang Thursday, December 2, 2010 5:39 AM
    Thursday, November 25, 2010 4:20 AM

All replies

  • Hi cruchy,

    For Word 2010, you could use a macro named 'PrintPreviewAndPrint' to intercept the File|Print command.


    Cheers

    macropod MS MVP - Word

    Wednesday, November 24, 2010 2:01 AM
  • Thanks Macropod.

    It does not work. I could find the macro named 'PrintPreviewAndPrint' macros in "Word commands". When I clicked it, I thought I could click on "Create" button on the right side but it was greyed out. All buttons were greyed out except for Organizer button.

    Many thanks

     

     

    Wednesday, November 24, 2010 3:01 AM
  • After selecting the command, you then need to change the "Macros in:" selection to have the Create button become enabled.

    -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "crunchy1821" wrote in message news:b3ac6d5c-cd5f-406f-a2cc-79fcb0ff1312@communitybridge.codeplex.com...

    Thanks Macropod.

    It does not work. I could find the macro named 'PrintPreviewAndPrint' macros in "Word commands". When I clicked it, I thought I could click on "Create" button on the right side but it was greyed out. All buttons were greyed out except for Organizer button.Many thanks


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    Wednesday, November 24, 2010 10:27 AM
  • I could get the Create button enabled. Thanks for your instruction.

    However, it still does not work, Doug.

    I have a very simple code that I want it to do as follows for testing only

    Sub PrintPreviewAndPrint()
    '
    ' PrintPreviewAndPrint Macro
    '
    '
      msgbox "Hello World"
    End Sub

    But when I went to File -> Print, it did not bring up the Hello World pop-up dialog box. Have I done anything wrong here. please correct me.

    Thank you

     

     

    Thursday, November 25, 2010 12:48 AM
  • There are many items in the Backstage view that have not been exposed to Visual Basic.  To intercept that command, you will need to customize the backstage view.

    See http://technet.microsoft.com/en-us/library/ff468686.aspx

    -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "crunchy1821" wrote in message news:a3eb598d-b0b0-47b1-a96c-1ba8ba9696be@communitybridge.codeplex.com...

    I could get the Create button enabled. Thanks for your instruction.

    However, it still does not work, Doug.

    I have a very simple code that I want it to do as follows for testing only

    Sub PrintPreviewAndPrint()
    '
    ' PrintPreviewAndPrint Macro
    '
    '
     msgbox "Hello World"
    End Sub

    But when I went to File -> Print, it did not bring up the Hello World pop-up dialog box. Have I done anything wrong here. please correct me.

    Thank you


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    • Marked as answer by Sally Tang Thursday, December 2, 2010 5:39 AM
    Thursday, November 25, 2010 4:20 AM
  • I'm sorry to say that this technique for intercepting Word commands is withering on the vine. The old, it seems, has no place in the new world order.
     

    Enjoy,
    Tony
    www.WordArticles.com
    Thursday, November 25, 2010 11:59 AM