c# ms word get visible text

There may be some problems with this:

  • Its not reliable. Are you truly able to get consistent results each time? For example, on a simple "=rand()" document, run the program 5 times in a row without changing the state of Word. When I do this, I get a different range printed to the console each time. I would first start here: there seems to be something wrong with your logic for getting the ranges. For example, rect.Left keeps returning different numbers every time I execute it against the same document left alone on screen
  • It gets tricky with other stories. Perhaps RangeFromPoint cannot
    extend across multiple story boundaries. However, lets assume it does. You would still need to enumerate each story e.g.

enumerator = r1.StoryRanges.GetEnumerator(); { while (enumerator.MoveNext() { Range current = (Range) enumerator.Current; } }

Have you tried to look at How to programmatically extract the text of the currently viewed page of an Office.Interop.Word.Document object ?