Get current mergefield on WindowSelectionChange RRS feed

  • Question

  • Hi,

    I can't retrieve the current mergefield from the WindowSelectionChange event, can you hellp me ?


    Globals.ThisAddIn.Application.WindowSelectionChange += new Microsoft.Office.Interop.Word.ApplicationEvents4_WindowSelectionChangeEventHandler(Application_WindowSelectionChange);

    void Application_WindowSelectionChange(Microsoft.Office.Interop.Word.Selection Sel)


    thanks !

    Friday, January 7, 2011 1:11 PM


  • Hi JeremieBaldy,

    Thank you for posting and we are glad to help with you.

    I did the test with your code, however it works well on my computer and my environment is Word2010+VS2010. And bellowing is the code:

            private void ThisAddIn_Startup(object sender, System.EventArgs e)
    Globals.ThisAddIn.Application.WindowSelectionChange +=
    new Word.ApplicationEvents4_WindowSelectionChangeEventHandler(Application_WindowSelectionChange);
    void Application_WindowSelectionChange(Microsoft.Office.Interop.Word.Selection Sel)

    After running the code and type some words into the word document, and then I change the selection with mouse, I can get the popup message.

    So, what's the version of your Office? Please try to test again whether it is ok.

    Best Regards,

    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Bruce Song Wednesday, January 12, 2011 2:45 AM
    • Marked as answer by Bruce Song Tuesday, January 18, 2011 9:47 AM
    Tuesday, January 11, 2011 2:34 AM