Passing value to word

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

How can I do this from within a vb.net app;

1. Create a word document from a word template and,

2 Pass a value to a variable defined within the document's VBA module?

Thanks

Regards
 
Let's say your word macro is:


Sub MyWordMacro(sStringParam As String)
MsgBox "This message comes from Word. The value passed is " &
sStringParam
End Sub

In your dotnet code you do:

Call oApp.Run("MyWordMacro", "Your Value")

Note: oApp is Word Application object and also you might have tp qualify the
macro name with module name.
 
I am trying to pass reference to a vb.net class so the word macro can call
procedures in that class. Is it possible to send references to classes this
way as well?

When I tried doing that I got a com exception in my vb.net app.

Thanks

Regards
 
In my word doc I have the following code (under this document);

Public Caller As EventHelper.EventHelper

Public Sub SetCaller(x As EventHelper.EventHelper)
MsgBox "I am here", , "Caller = x"
Caller = x '<-- This line causes exception in my vb.net app
' the macro runs fine from vb.net app if the above line
is commented out
End Sub
 
Back
Top