Is there any way to identify the specific instance of word that a vb.net applcation creates

objWord = New Microsoft.Office.Interop.Word.Application

        objWord.Documents.Open("C:\TestFile.rtf")
        objWord.Visible = True

In the text above how can identify this instance of word to close it after a specific event or period of time.

Probably the only way is to maintain reference to document:

Dim DocInstance1 As Word.Document
Dim DocInstance2 As Word.Document

DocInstance1 = objWord.Documents.Open("D:\a.doc")
objWord.Visible = True

DocInstance2 = objWord.Documents.Open("D:\b.doc")
objWord.Visible = True

And then close the unneeded instance when the wanted condition is met: DocInstance1.Close() Of course, instances should be in array or similar structure.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.