N
Nam
“Without closing†an already open word document, how can we use a VB6 program
to run a macro of that open document? I know how to do this by opening the
document that was closed, as follows:
Dim oApp As Word.Application
Dim oDoc As Word.Document
Set oApp = New Word.Application
Set oDoc = oApp.Documents.Open("C:\Test.doc")
oApp.Run "Macro1", Param1
oDoc.Save
oDoc.Close
oApp.Quit
The reason I want to do it for an already open document is that I want my
VB6 program to insert a certain text at the insertion point (where the cursor
is) of the document. Doing this task through a word macro is simple, running
the following macro will insert the desired text at the insertion point:
Sub Macro1(str As String)
Selection.TypeText Text:="Text to be entered"
End Sub
But I need to use my VB6 program since it does several other tasks besides
Word Automation.
Thanks,
Nam
to run a macro of that open document? I know how to do this by opening the
document that was closed, as follows:
Dim oApp As Word.Application
Dim oDoc As Word.Document
Set oApp = New Word.Application
Set oDoc = oApp.Documents.Open("C:\Test.doc")
oApp.Run "Macro1", Param1
oDoc.Save
oDoc.Close
oApp.Quit
The reason I want to do it for an already open document is that I want my
VB6 program to insert a certain text at the insertion point (where the cursor
is) of the document. Doing this task through a word macro is simple, running
the following macro will insert the desired text at the insertion point:
Sub Macro1(str As String)
Selection.TypeText Text:="Text to be entered"
End Sub
But I need to use my VB6 program since it does several other tasks besides
Word Automation.
Thanks,
Nam