Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all articles
Browse latest Browse all 1741

New Post: How can I connect to the current instance of an application by the file name?

$
0
0
Hi.

I'm also very much interested in this.

I'm writing a companion product for Word. (but not a plugin).

From the companion app, I need to find Word instance of a given filename.

But it doesn't seem to work.

If I have 3 word instances open, and I do this:
                foreach (Application word_application in Application.GetActiveInstances())
                {
                    foreach (Window window in word_application.Windows)
                    {
                        if (filename == window.Document.FullName)
                        {
                            //Do good stuff here
                        }
                    }
                }

it doesn't work.

Application.GetActiveInstances() returns 3 applications,

but window is always the same, first instance.

How can I get to the file I need?

Many thanks.

Viewing all articles
Browse latest Browse all 1741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>