Word Statusbar gets reset when I use range.Information

190 views Asked by At

I have the following code (simplified to show the problem):

var wdApp = new Application();
var wdDoc = wdApp.Documents.Open("C:\foo.docx");
wdApp.StatusBar = "Updating...";

var rng = wdDoc.Range(10, 10);
if ((bool)rng.Information(WdInformation.wdWithInTable))
{

}

//StatusBar value is gone...
  • What could be the reason?
  • How can I prevent it?
  • Do you know of other situations where this can happen?

Here screenshots of the problem

1 F10 (step over) later

Edit:

The provided code uses NetOffice and not the interop library from Microsoft directly, therefor the syntax is correct. You may notice in the provided screenshots that they are taken from a running application. Breakpoint, highlighting of current line of code executing, aswell as the actual result of the code in the word application on the right. Where at first there is the desired statusbar "Tabelle 8 von 17 wird neu erstellt." (Table 8 out of 17 is recreating) and at the next step my statusbar is gone and its the default stuff "165 von 8227 Wörtern" (165 out of 8227 words)

1

There are 1 answers

0
bic On

What could be the reason?

I believe this is to do with the library you are using. I tested your code but with the Word Interop library, and the only way I could get the status bar to reset was to manually click/type within the Word window.

How can I prevent it?

I would say take a look into the code base of library you are using. It is likely that it is doing something that is causing the behaviour. Unless there is a specific reason you are using NetOffice I would suggest switching to the either the standard Interop or VSTO.

Do you know of other situations where this can happen?

As above, I could only get the status bar to reset if I manually carried out some sort of input into the window.