none
Get coordinates of a range or caret in e-mail body RRS feed

  • Question

  • Hello,

    I'm trying to get the X, Y coordinates of a range in the e-mail body so that I can pop up a little modal underneath what the user is typing in an e-mail if certain words are typed.  I believe I have it almost working.  Using the WordEditor property of the current inspector, I can get a Word.Range object which is the keyword that should trigger the modal (and location I want to find).  I found some documentation online saying that from a Word.Window object, i can call the .GetPoint property to get the position of a range, however.. when I try to call the Word.Document's .ActiveWindow property, I get the following error: "This object model command is not available in e-mail.".  Does anyone have any idea how to get the Word.Window object out of the WordEditor?  Or have any other ideas on how I can get the X, Y coordinates for a given word typed into an e-mail body? Here is my code:

    Word.Range rng = find.Parent as Microsoft.Office.Interop.Word.Range;
    
    Word.Document doc = rng.Document;
    
    Word.Window w = doc.ActiveWindow;
    
    					
    int left = 0;
    int top = 0;
    int width = 0;
    int height = 0;
    
    w.GetPoint(out left, out top, out width, out height, rng);

    Thanks!

    Monday, May 13, 2013 4:06 PM

Answers