VBA function results in fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is it possible to have a document field return the result of a macro
function? I'm hopeing to have a field that would call a particular function
each time it is updated and display the results. It's important that I'm able
to pass a parameter to the function. The function might look sometimg like:


public function foo(param as integer) as string

.....
'some calculations
......

foo = "my string"

end function


I'm aware that it's possible to update fields from macros but is it possible
to have a field update itself?
 
You have posted this in an end-user NG; you would get a better response if
you post in one of the word.vba (programming) NGs.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
Use a double-barrel approach: insert a DocProperty or DocVariable field to
display your variable; then in your macro use the result to set the value of
the document property or document variable and update fields.
 
Hi =?Utf-8?B?Um9iZXJ0IE11bHJvbmV5?=,
Is it possible to have a document field return the result of a macro
function? I'm hopeing to have a field that would call a particular function
each time it is updated and display the results. It's important that I'm able
to pass a parameter to the function.
No, this simply is not possible in Word. Too bad...

Closest you could get in Word would be a MacroButton field that the user would
have to click.

Other than that, I can only imagine using something as a macro trigger (either a
keyboard shortcut or a specific application event) to update information in the
document. There are various things you could use as a "target".

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top