G
Guest
Hi all, I'm creating a VB 2005 program which deal with MS Word Document. The
program allows users to select/put cursor on any Word doc that shown on the
screen and hit any button on my program to perform some task on the selected
document. There could be a few word docs opened on the screen.
Now, my question is... how do get the object of the user's selected word
doc? I tried the following codes, but it didn't point/refer to the user's
selected word doc.
Dim tWord As Microsoft.Office.Interop.Word.Application
Dim tDoc As Microsoft.Office.Interop.Word.Document
tWord = GetObject(, "Word.Application")
tDoc = tWord.ActiveWindow.Document
Please assume that the Word docs that shown on the screen might NOT be
already saved. So the window title of each Word doc could be "Document 1",
"Document 2" or "Document 3".
Please help if you know the answer. Thanks.
program allows users to select/put cursor on any Word doc that shown on the
screen and hit any button on my program to perform some task on the selected
document. There could be a few word docs opened on the screen.
Now, my question is... how do get the object of the user's selected word
doc? I tried the following codes, but it didn't point/refer to the user's
selected word doc.
Dim tWord As Microsoft.Office.Interop.Word.Application
Dim tDoc As Microsoft.Office.Interop.Word.Document
tWord = GetObject(, "Word.Application")
tDoc = tWord.ActiveWindow.Document
Please assume that the Word docs that shown on the screen might NOT be
already saved. So the window title of each Word doc could be "Document 1",
"Document 2" or "Document 3".
Please help if you know the answer. Thanks.