Openeing a process. Problems

S

stefan.sedich

Hi im trying to open a word document in word. Like this:

Process p = new Process();
p.EnableRaisingEvents = false;
string mFileName = @"c:\a.doc";
p.StartInfo.FileName = mFileName;

p.Start();
while ((int)p.MainWindowHandle == 0) {
p.Refresh();
}

My problem is that when it hits the mainwindowhandle bit, it says:

Process has exited, so the requested information is not available.

This technique works for other applications just doesnt seem to work
for word or outlook, works fine for excel and powerpoint!!

Any ideas here..


Thanks
 
M

Marc Gravell

So it sounds like Word and Outlook are simply forwarding their
arguments to an already-running process (exe) instance and then
exiting... quite a good idea for some apps.

Have you tried using the interop assemblies to talk to Word? Just add a
COM reference, and do it that way? Or do you need the native Win32
handle?

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top