C# Word Addin - Get selected text OR read all

Dec 18, 2013 at 9:49 AM
Hi all,

I am programming a Word Addin in C# using Netoffice. I want to get selected text or (if nothing is selected) all text.

I found that snippet:

   string selectText = string.Empty;
   Word.Selection wordSelection = this.Application.Selection;
    if (wordSelection != null && wordSelection.Range != null)
    {
        selectText = wordSelection.Text;
    }
But now I need an else which selects the whole text in the word document.

Does anybody knows how to do that?
Mar 4, 2014 at 5:34 AM
u can select the whole text of the document
Word.Range rng = this.Content;
rng.Select();