Eugene S.B.

range.Select(); //line 1

float X = (float) ((Microsoft.Office.Interop.Word.ApplicationClass) _application).Selection.get_Information(WdInformation.wdHorizontalPositionRelativeToPage); //line 2

If I set breakpoint at line 1 and stop in debugger, I get another value in line 2. Selected range is located in table cell. May be I have to invoke some refresh function or something else before line 2. I don't really understand why I get different values for the same file and the same range in Debugger and without debugger.



Re: Visual Studio Tools for Office Why do MS Word Automation return different values with and without Debugger?

Eugene S.B.

I want to declare what I found. If I add some delay between loading of word document and processing the objects - all works fine. I think MS Word do some loading asynchronously, so I have to wait for ending of initialization.



Re: Visual Studio Tools for Office Why do MS Word Automation return different values with and without Debugger?

Cindy Meister

Hi Eugene

Your thoughts are on the right track, I think :-) When loading a document, what takes time is the pagination and layout of the page. Tables are notoriously slow. So if you're are querying this immediately after opening, or perhaps even editing table content, it makes sense that the value being returned might not be stabile.

Perhaps a loop that compares the value two or three times and only ends when the value is the same two or three times running






Re: Visual Studio Tools for Office Why do MS Word Automation return different values with and without Debugger?

Eugene S.B.

Cindy Meister wrote:

Perhaps a loop that compares the value two or three times and only ends when the value is the same two or three times running

I think loop that compares the value two or three times is not reliable solution because we can get wrong value several times.

I solve the problem by adding:

Thread.Sleep(1000);//Waiting for 1 second

after opening the document.