Discussion:
Paste data to already open word document.
(too old to reply)
musa.biralo
2009-07-05 01:29:30 UTC
Permalink
Hello and Greetings:

I am trying to paste my text to already open word document using VSTO,
VB.NET. I have the file name of the open word document in my task bar.

Let's say, "Docuement 1 - Microsoft Word" is open and I can see that
in my taskbar. Now how can i activate the "Docuement 1 - Microsoft
Word" and paste a string to it?

If I do "Dim wordApp As New Word.Application", this will create new
word document which i don't want. And if I just use "Dim wordApp As
Word.Application" will throw null reference error.

I am trapped. Please carry me out.

Musa.Biralo.
Tomy Varghese
2009-08-03 09:35:14 UTC
Permalink
Post by musa.biralo
I am trying to paste my text to already open word document using VSTO,
VB.NET. I have the file name of the open word document in my task bar.
Let's say, "Docuement 1 - Microsoft Word" is open and I can see that
in my taskbar. Now how can i activate the "Docuement 1 - Microsoft
Word" and paste a string to it?
If I do "Dim wordApp As New Word.Application", this will create new
word document which i don't want. And if I just use "Dim wordApp As
Word.Application" will throw null reference error.
I am trapped. Please carry me out.
Musa.Biralo.
Did you try something like

Dim Word.Application as oWordApp =
DirectCast(System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application"),
Word.Application)

Tomy

Continue reading on narkive:
Loading...