none
How to get the screen coordinates of a range in outlook (word editor) RRS feed

  • Question

  • Hi All,

        First, thank you for viewing my topic. I'm developing an addin for Office 2007 by VS2008. I want to get the screen coordinates of a range. I have googled and found this method: ActiveWindow.GetPoint(). It works pretty well in Word. But when I try to use this method in Outlook/Word Editor, the framework throws an exception that this method is not supported in Outlook.

        So I just wonder if there are any work around to get the screen coordinates of a range in outlook (word editor)?

        Thank you again.


    Whatever happens , we shall keep going on.
    Friday, August 5, 2011 1:41 PM

Answers

  • I'm out of ideas on this, it just may not be possible to get any more granular in getting screen position in the Outlook WordMail editor.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Justin.CHG" <=?utf-8?B?SnVzdGluLkNIRw==?=> wrote in message news:6b64b51d-e4fe-42c9-9213-d67b60161c43...

    Hi Ken,

        Thank you for you reply. I have followed your suggestion and tried to convert Outlook Active Window to Word Window but failed. And I can use FindWindow() and GetWindowPos() to get the position of current window, but not the position of selected range.

        Also, I have tried these codes.

     Word.Document doc = Globals.ThisAddIn.Application.ActiveInspector().WordEditor as Word.Document;
     if (doc == null)
     {
      return;
     }
    
     double x = Convert.ToDouble(doc.Application.Selection.get_Information(Word.WdInformation.wdHorizontalPositionRelativeToPage));
     double y = Convert.ToDouble(doc.Application.Selection.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage));
    

        I can get the x value and the y value is always -1.0.  Do you have any suggestion for this?

    Thank you,

    Justin Zhang

     


    Whatever happens , we shall keep going on.

    Ken Slovak MVP - Outlook
    Monday, August 8, 2011 1:35 PM

All replies

  • The Word editor in Outlook is a limited subset of the Word application, so some things may not work as expected from the full Word.
     
    How are you getting the window? Are you using Inspector.WordEditor.ActiveWindow?
     
    Inspector.WordEditor would be the active Word.Document object.
     
    Another possibility to try would be to try to cast the Outlook.Application.ActiveWindow object (which is an IOLEWindow object) to a Word.Window object. I don't know that this would work, but it's worth trying.
     
    If neither of those works about all I can think of would be to get the position of the Document window, which can be done by using PInvokes of FindWindow() and then GetWindowPos().

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Justin.CHG" <=?utf-8?B?SnVzdGluLkNIRw==?=> wrote in message news:c9811de5-a478-4ead-96f4-43718a00abfc...

    Hi All,

        First, thank you for viewing my topic. I'm developing an addin for Office 2007 by VS2008. I want to get the screen coordinates of a range. I have googled and found this method: ActiveWindow.GetPoint(). It works pretty well in Word. But when I try to use this method in Outlook/Word Editor, the framework throws an exception that this method is not supported in Outlook.

        So I just wonder if there are any work around to get the screen coordinates of a range in outlook (word editor)?

        Thank you again.


    Whatever happens , we shall keep going on.

    Ken Slovak MVP - Outlook
    Friday, August 5, 2011 3:59 PM
  • Hi Ken,

        Thank you for you reply. I have followed your suggestion and tried to convert Outlook Active Window to Word Window but failed. And I can use FindWindow() and GetWindowPos() to get the position of current window, but not the position of selected range.

        Also, I have tried these codes.

     Word.Document doc = Globals.ThisAddIn.Application.ActiveInspector().WordEditor as Word.Document;
     if (doc == null)
     {
       return;
     }
    
     double x = Convert.ToDouble(doc.Application.Selection.get_Information(Word.WdInformation.wdHorizontalPositionRelativeToPage));
     double y = Convert.ToDouble(doc.Application.Selection.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage));
    

        I can get the x value and the y value is always -1.0.  Do you have any suggestion for this?

    Thank you,

    Justin Zhang

     


    Whatever happens , we shall keep going on.
    Saturday, August 6, 2011 7:23 AM
  • I'm out of ideas on this, it just may not be possible to get any more granular in getting screen position in the Outlook WordMail editor.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Justin.CHG" <=?utf-8?B?SnVzdGluLkNIRw==?=> wrote in message news:6b64b51d-e4fe-42c9-9213-d67b60161c43...

    Hi Ken,

        Thank you for you reply. I have followed your suggestion and tried to convert Outlook Active Window to Word Window but failed. And I can use FindWindow() and GetWindowPos() to get the position of current window, but not the position of selected range.

        Also, I have tried these codes.

     Word.Document doc = Globals.ThisAddIn.Application.ActiveInspector().WordEditor as Word.Document;
     if (doc == null)
     {
      return;
     }
    
     double x = Convert.ToDouble(doc.Application.Selection.get_Information(Word.WdInformation.wdHorizontalPositionRelativeToPage));
     double y = Convert.ToDouble(doc.Application.Selection.get_Information(Word.WdInformation.wdVerticalPositionRelativeToPage));
    

        I can get the x value and the y value is always -1.0.  Do you have any suggestion for this?

    Thank you,

    Justin Zhang

     


    Whatever happens , we shall keep going on.

    Ken Slovak MVP - Outlook
    Monday, August 8, 2011 1:35 PM
  • Hi Ken, No Problem, thank you for providing me suggestion. I try to use an work around now, using the mouse cursor location instead for now. Although it is no so good, I don't think I have another choice for now.
    Whatever happens , we shall keep going on.
    Tuesday, August 9, 2011 3:42 AM