1

I am using the following code to find some strings in my document:

Application application = Addin.Application;
Document document = application.ActiveDocument;
Range rng = document.Content;

rng.Find.ClearFormatting();
rng.Find.Forward = true;
rng.Find.Text = findText;

while (rng.Find.Execute() && rng.Find.Found)
{
    // here this is always rng.TextVisibleOnScreen == -1
}

According to the documentation:

The TextVisibleOnScreen property returns 1 if all text in the range is visible; it returns 0 if no text in the range is visible; and it returns -1 if some text in the range is visible and some is not. Text that is not visible could be, for example, text that is in a collapsed heading.

However the property is always -1 even when the text is not on the screen at all or when all the text is on the screen... Is this a known issue? Am I doing something wrong?

Leo
  • 5,013
  • 1
  • 28
  • 65
  • 4
    This has been asked before, please see [Word.Range.TextVisibleOnScreen?](https://stackoverflow.com/questions/49821429/word-range-textvisibleonscreen) – Cindy Meister Mar 14 '19 at 17:56
  • @CindyMeister - it kind of has, but it is a VBA question rather than VSTO / netoffice... – Leo Mar 15 '19 at 12:01

0 Answers0