0

i am trying to create word 2007 add-in using VS2008, and i need to know how to get the selected text inside the word document

Fionnuala
  • 90,370
  • 7
  • 114
  • 152
  • It is most unlikely that you will get an answer unless you post a little existing code to at least show where the selected text is coming from. – Fionnuala Dec 06 '11 at 14:33

1 Answers1

2

i have found the solution:

using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;

public String getSelected(){
    Word.Document app = add_in.Globals.ThisAddIn.Application.ActiveDocument;
    String keyword = app.Application.Selection.Text;
    return keyword;
}