We are having a problem experienced by a few users when attempting to launch Word from our application via the office interop:
using Word = Microsoft.Office.Interop.Word;
public void ShowWord()
{
_word = new Word.ApplicationClass();
_word.Visible = true;
_word.Activate();
}
If word is not always open a COM exception is thrown stating "Cannot activate application." Adding a Thread.Sleep(1000)
before calling _word.Activate()
prevents this, but obviously is not ideal.
public void ShowWord()
{
_word = new Word.ApplicationClass();
_word.Visible = true;
Thread.Sleep(1000)
_word.Activate();
}
Has anyone seen this before and knows what is causing this and what the right way to fix this is?