I’m check to see if Word is still visible before I perform certain tasks. The problem is execution just freezes after I close Word 2010 on the check of the visibility. Does not occur with 2007.
//Initializing Word and Document
While(WordIsOpen())
{
}
//Perform Post Close Tasks
public bool WordIsOpen()
{
if(MyApp.Application.Visible)//Execution just freezes at this line after Word is not visible
return true;
else
return false;
}
Anyone see this issue before?
Is there a better way to check this?
My suggestion would be to declare a sentinel flag:
When initializing your
Applicationinstance, subscribe to itsQuitevent, and reset the flag from there:Then, in your loop, just check whether the flag is set:
Edit: Given that you only need to wait until the Word application is closed, the following code might be more suitable: