Hi!
I'm working on a VSTO Word Addin that helps the user to replace certain words in a given text. A dialog guides the user through the replacements. Now, when the user replaces the last word I want to display a MessageBox that he is done. There I'm struggeling with a timing issue. The MessageBox appears before the last replacement is visible. Even though, the code line for the replacement is executed before. After clicking the MessageBox away the replacement is made as should be.
Here is the line I use to replace the word:
using Microsoft.Office.Interop.Word;
...
Words wordsText = Globals.ThisAddIn.Application.ActiveDocument.Words;
...
wordsText[wordPos].Text = "[some text]";
And this is my MessageBox displayed later:
MessageBox.Show(this._owner, "[you are done text]", "[title]", MessageBoxButtons.OK, MessageBoxIcon.Information);
I noticed that if I set a breakpoint on the line above in Visual Studio the replacement is made correctly before the appearance of the MessageBox. Can I somehow force changes in Microsoft.Office.Interop.Word.Words
to apply instantly? Any other ideas?
wordPos
? – etaiso