E
Evan Stone
Hi,
What I'd like to do is attach to an instance of Word (if it's running), and
if it's not running then create a new instance of the application. To that
end, I was wondering if the following was a valid use of the
Activator.GetObject() method:
public Word.ApplicationClass CreateWordApplicationInstance()
{
Type wordType = Type.GetTypeFromProgID("Word.Application");
Word.ApplicationClass app = null;
try
{
app = Activator.GetObject(wordType, "");
}
catch(Exception rex)
{
app = new Word.ApplicationClass();
}
return app;
}
Thanks!
evan k. stone | software engineer
What I'd like to do is attach to an instance of Word (if it's running), and
if it's not running then create a new instance of the application. To that
end, I was wondering if the following was a valid use of the
Activator.GetObject() method:
public Word.ApplicationClass CreateWordApplicationInstance()
{
Type wordType = Type.GetTypeFromProgID("Word.Application");
Word.ApplicationClass app = null;
try
{
app = Activator.GetObject(wordType, "");
}
catch(Exception rex)
{
app = new Word.ApplicationClass();
}
return app;
}
Thanks!
evan k. stone | software engineer