0

I have an application which embeds an instance of word 2007 inside of it. Everything works fine except until I open a fresh instance of word 2007 from the start menu. Instead of opening a new instance of word it finds my instance and loads a blank document inside of it. Is there a registry setting that will force word to always start in a new instance or some way to mark my instance of word so that it doesn't get hijacked? Anyone else out there seen this happen?

1
Contributor
1
Reply
2
Views
8 Years
Discussion Span
Last Post by chriswininger
1

I seem to have found my own solution and I want to post it. I have seen this issue discussed on other threads and have yet to see a solution. Here is what worked for me (I'm using Visual Studio 2003 and Word 2007). I put an event handler on my instance of Word.Application which listens for the Open_Document event. I also added a special character sequence to the name of any document I create inside of my application. Now any time the open document event is fired it checks for that character sequence. If it is there it allows the document to open inside my instance of word. If it is not there then the application stores the path and file name of the document, closes the document, then spawns a new instance of word and passes the file path to the new instance. You may see a graphical hiccup where the document appears in your application for a second prior to closing but in experimentation on my machine this was rare and brief.

If Doc.Name.ToLower.IndexOf("nbdr") < 0 Then
                oWordApp.ActiveDocument.Close()
                Dim newWordApp As New Word.Application
                Doc = newWordApp.Documents.Open(path & "\" & file)
                newWordApp.Visible = True
                ' BDWordWindow1.RaiseBillOpenedEvent()
   End If

I have an application which embeds an instance of word 2007 inside of it. Everything works fine except until I open a fresh instance of word 2007 from the start menu. Instead of opening a new instance of word it finds my instance and loads a blank document inside of it. Is there a registry setting that will force word to always start in a new instance or some way to mark my instance of word so that it doesn't get hijacked? Anyone else out there seen this happen?

Votes + Comments
Great Follow Up!
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.