Controlling wordwin.exe in automation application

S

Sirch

I have Automation application written in C# that creates Word documents. The
application works fine, however, if a user opens Word or opens a Word
document while my application is running, the user initiated action attaches
to the process (winword.exe) that my automation application created. How do
I prevent this from happening? In other words, if the user opens Word or
opens a Word document how do I force the system to give them there own
winword.exe process and not attach to the winword.exe process my automation
application created?

--Sirch
 
C

Cindy M.

Hi Sirch,
I have Automation application written in C# that creates Word documents. The
application works fine, however, if a user opens Word or opens a Word
document while my application is running, the user initiated action attaches
to the process (winword.exe) that my automation application created. How do
I prevent this from happening? In other words, if the user opens Word or
opens a Word document how do I force the system to give them there own
winword.exe process and not attach to the winword.exe process my automation
application created?
You can't, short of changing the registered shortcuts on the user's machine to
always open a new instance of the application each time a shortcut is executed.
This was how Word (indeed, most Office applications) were designed to work - one
instance only.

About the only thing you could do would be to start an instance for the user
before you start your own. That first instance is the one that will be
registered in the ROT and will be invoked when a shortcut is executed.

Of course, if the user would quit that instance, then start a new one later, it
would again pick up your instance. So your application might have to monitor the
one it starts for the user and prevent it quitting. Or also quit your instance,
then restart both again...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
D

Dirk Frulla

I have found a way around this issue. There was a knowledge base article
about it, however, I do not have the link handy. In short you have to create
two Word application objects and use the second one, closing the first.

Like this:

Dim app1 As New Word.Application
Dim app2 As New Word.Application

app1.Quit()

Now use "app2" to do all of your automation. It is very strange, but it
works fine for me.

Hope this helps. :)
 
C

Cindy M.

Hi Dirk,
I have found a way around this issue. There was a knowledge base article
about it, however, I do not have the link handy
Was it this one:

http://support.microsoft.com/kb/188546/

Interesting, I hadn't seen that before. Thank you. I do see, however, that
it doesn't apply if the user double-clicks a document to start Word (the
"note" at the end of the article).

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
D

Dirk Frulla

Yes, that's it! Thanks for the link.

Unfortunately, you are correct about double-clicking a document.

Our office automates Word quite a bit. We were finally able to get around
this issue by creating a production service. The service runs as a different
user, and usually runs at night.

Maybe a combination of these will help the original poster.
 

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