WindowBeforeDoubleClick event doesn't fire in Outlook2013 VSTO Add-in RRS feed

  • Question

  • Hi Friends,

    I'm using VS2015 Office VSTO to design an Add-in for outlook. There is a simple requirement in the implementation.

    Recognize the double-clicked characters in mail writing window. So, I just created a new project which only contains ThisAddIn.cs.

    Here is the full source code. Because inspector.WordEditor is not fully initialized while getting a new inspector, I have to use Inspector.Activate event to register event "WindowBeforeDoubleClick". In debug mode, I see Inspector_Activate is executed well, but nothing will happen if I double click text in writing mail window.

    This is my first post in Microsoft Tech Forum, your help is very appreciated. Thank you very much!

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Xml.Linq;
    using Outlook = Microsoft.Office.Interop.Outlook;
    using Word = Microsoft.Office.Interop.Word;
    using Office = Microsoft.Office.Core;
    namespace FirstOutlookAddIn
        public partial class ThisAddIn
            Outlook.Application application = null;
            Outlook.Inspectors inspectors = null;
            Outlook.Inspector activeInspector = null;
            Word.Document document = null;       
            private void ThisAddIn_Startup(object sender, System.EventArgs e)
                // Get the Application object
                application = this.Application;
                // Get the Inspector object
                inspectors = application.Inspectors;
                //Add a new Inspector
                inspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(Inspectors_RegisterEventWordDocument);
            private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
                // Note: Outlook no longer raises this event. If you have code that 
                //    must run when Outlook shuts down, see
            private void Inspectors_RegisterEventWordDocument(Outlook.Inspector inspector)
                activeInspector = inspector;
                ((Outlook.InspectorEvents_10_Event)inspector).Activate += new Outlook.InspectorEvents_10_ActivateEventHandler(Inspector_Activate);
            private void Inspector_Activate()
                document = activeInspector.WordEditor as Word.Document;
                document.Application.WindowBeforeDoubleClick +=
                                    new Word.ApplicationEvents4_WindowBeforeDoubleClickEventHandler(
                ((Outlook.InspectorEvents_10_Event)activeInspector).Activate -= new Outlook.InspectorEvents_10_ActivateEventHandler(Inspector_Activate);
            private void ApplicationOnWindowBeforeDoubleClick(Word.Selection selection,
                ref bool cancel)
                // Get the selected word
                Word.Words words = selection.Words;
                MessageBox.Show("Selection: " + words.First.Text);
            #region VSTO generated code
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InternalStartup()
                this.Startup += new System.EventHandler(ThisAddIn_Startup);
                this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);

    Saturday, April 8, 2017 5:39 AM

All replies

  • Hi,

    Here we mainly focus on Office client related question and feedback. For your specific question, I will move it to the following dedicated development forum, there you should get more professional responses:

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.


    Ethan Hua

    Please remember to mark the replies as answers if they helped.
    If you have feedback for TechNet Subscriber Support, contact

    Monday, April 10, 2017 6:20 AM
  • Hello,

    I test the code above and it works for me.

    I suggest you add breakpoint at ApplicationOnWindowBeforeDoubleClick event to check if the event would be triggered. Please disable all other add-ins before testing and confirm your add-in is successfully load.



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Tuesday, April 11, 2017 8:23 AM