473,386 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Passing value to word

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
Nov 20 '05 #1
3 2834
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.
Nov 20 '05 #2
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
"John Smith" <Jo**@Y.com> wrote in message
news:O1**************@TK2MSFTNGP09.phx.gbl...
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.

Nov 20 '05 #3
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
"John Smith" <Jo**@Y.com> wrote in message
news:O1**************@TK2MSFTNGP09.phx.gbl...
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.

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Richard | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** HI, I am working on a project where I need to input data to a (local) HTML page using multiple form elements, such as text,...
20
by: christopher diggins | last post by:
I have heard it is considered good practice to pass function parameters as const& as often as possible, is this true? Is it possible to go overboard? And if so why? Thanks a lot in advance...
10
by: vbMark | last post by:
Hello, I am doing this: window.location="page2.php?subj="+subj+"&body="+body; to send information to another page. However, I don't want that second page to show up or display in any way....
10
by: Geoff Cox | last post by:
Hello, I have written before that I can pass a variable from page 1 to page 2 if I call the variable "name". Stephen Chalmers has written, >'name' is effectively a reserved word as the...
0
by: Neelima Godugu | last post by:
Hi All, I have developed a windows forms user control, which I am going to host in Internet Explorer.. I am familiar with the security settings requirement inorder to do the above. I have...
0
by: SWcisel | last post by:
I've been working with VBA for Microsoft Access for a few months now, and now I've got a small task to complete using VBA in Microsoft Word 2003. There are three offices that my company works with,...
11
by: =?Utf-8?B?U3VqZWV0?= | last post by:
If there are long strings (like 1MB or 2MB) is it more performant to pass those by ref to methods or by value?
13
by: masso600 | last post by:
char word; in = fopen("test.txt", "r"); while(fscanf(in,"%s",&word)!=EOF) { /* Print all words */ /* printf("%s\n",&word); */
4
by: arnuld | last post by:
I am passing an array of struct to a function to print its value. First I am getting Segfaults and weired values. 2nd, is there any elegant way to do this ? /* Learning how to use an array...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.