none
ActiveInlineResponseWordEditor not working in Explorer mode RRS feed

  • Question

  • We are working on a VSTO add-in for Outlook and we have added a custom action for hyperlinks on the ribbon menu.

    In the handler of the custom action we want to resolve the URL and display text of the link.

    When in the Inspector context grabbing the word editor and getting the selection from that works as expected:

    if (control.Context is Inspector inspector) 
                {
                    var document = inspector.WordEditor;
                    
                    if (document != null && document.Windows != null && document?.Windows.Count > 0)
                    {
                        Microsoft.Office.Interop.Word.Selection selection = document?.Windows[1].Selection;
                        if (selection?.Hyperlinks != null && selection.Hyperlinks.Count > 0)
                        {
                            // works
                        }
                    }
                }

    When in the Explorer context though I get a COMException (without any details) when trying to access the ActiveInlineResponseWordEditor property of the Explorer object.

    Is this a bug or am I doing something wrong?

    Thursday, August 9, 2018 10:24 AM

Answers

All replies

  • What is the exact exception?

    When exactly do you access the Explorer.ActiveInlineResponseWordEditor property?

    Keep in mind that the object might not be immediately available.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, August 9, 2018 6:26 PM
  • The exception is just a COMException: 

    System.Runtime.InteropServices.COMException occurred
      HResult=0x88304002
      Message=The operation failed.
      Source=Microsoft Outlook
      StackTrace:
       at Microsoft.Office.Interop.Outlook._Explorer.get_ActiveInlineResponseWordEditor()

    This happens on the 'onAction' handler for the context menu.

    I did consider that the object might not be immediately available so I tried to delay accessing it with different timespans but every time I get the same exception.

    Monday, August 13, 2018 10:46 AM
  • How did you delay the access? You are still on the main Outlook thread and Outlook is still executing the handler. The only way to delay is to use a Timer (use the one fron the Windows.Forms namespace as it executes on the same thread) - enable the timer in the event handler, when the timer fires a few milliseconds later, you will be out of the menu click action menu handler: disable the timer and execute your code.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, August 13, 2018 4:33 PM
  • Thanks for your response.

    As I did mention in my previous response I did try delaying it (with a Forms Timer) with the same result.

    Tuesday, August 14, 2018 12:18 PM
  • Does it work from OutlookSpy? Click Explorer, select ActiveInlineResponseWordEditor, click Browse.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, August 14, 2018 2:07 PM
  • Neat tool.

    But no, it doesn't work. It comes up as null

    Thursday, August 16, 2018 6:58 AM
  • Do you have an inline response active at the time you access that property through OutlookSpy?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, August 16, 2018 3:35 PM
  • No, I don't. I see what you mean. But then, how would I get the hyperlink URL and display text that the user right-clicked on? 

    • Edited by g.christou Friday, August 17, 2018 6:13 AM
    Friday, August 17, 2018 6:12 AM
  • Use Explorer.PreviewPane.WordEditor (available in the latest versions of Outlook 2016 only).

    Or use Redemption and its SafeExplorer object - it exposed ReadingPane property in all versions of Outlook.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by g.christou Friday, August 17, 2018 10:41 AM
    Friday, August 17, 2018 6:54 AM
  • Cool! PreviewPane does the job. Thanks
    Friday, August 17, 2018 10:41 AM