473,397 Members | 1,969 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,397 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 2835
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.