Field And Macro

I

Idle

Is it possible to call a macro from a field and use macro's return value in
the same field?

Thanks
 
J

Jean-Guy Marcil

Idle was telling us:
Idle nous racontait que :
Is it possible to call a macro from a field and use macro's return
value in the same field?

It depends... what are you trying to do?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
I

Idle

Is it possible to call a macro from a field and use macro's return
It depends... what are you trying to do?

I have a little math requiring loops and data from files, it's all done in
VBA. The result needs to be in a field that's on every page (header). So,
each field has its belonging page number.
I thought if its possible to use page number as a parameter for macro
that'll return result of calc to it's corresponding field.

Example headers: (let's say the calculus is result = pg.num. * 2)
page 1: PAGE 1 - 2
page 2: PAGE 2 - 4
page 3: PAGE 2 - 6
page 4: PAGE 2 - 8
etc.

It's not as simple as this and it uses data from files, as I said.

Also I know that it's possible to write from VBA to every bookmark in the
document or anywhere for that matter. The problem is that the number of
pages is variating. That's way I thought that header would be better.

Thanks
 
J

Jean-Guy Marcil

Idle was telling us:
Idle nous racontait que :
I have a little math requiring loops and data from files, it's all
done in VBA. The result needs to be in a field that's on every page
(header). So, each field has its belonging page number.
I thought if its possible to use page number as a parameter for macro
that'll return result of calc to it's corresponding field.

Example headers: (let's say the calculus is result = pg.num. * 2)
page 1: PAGE 1 - 2
page 2: PAGE 2 - 4
page 3: PAGE 2 - 6
page 4: PAGE 2 - 8
etc.

It's not as simple as this and it uses data from files, as I said.

Also I know that it's possible to write from VBA to every bookmark in
the document or anywhere for that matter. The problem is that the
number of pages is variating. That's way I thought that header would
be better.
Thanks

When does this calculating need to be done?

When creating a document? When opening a document? Both
Once? Whenever the user decides to? Automatically every nth period x of
time? etc.


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
I

Idle

When creating a document? When opening a document? Both
Once? Whenever the user decides to? Automatically every nth period x of
time? etc.

I guess it doesn't matter... When user decides to.
 
J

Jean-Guy Marcil

Idle was telling us:
Idle nous racontait que :
I guess it doesn't matter... When user decides to.

Well, if you are going top write code for this, you have to decide. It
certainly does matter because the code you will use will be different
depending on the answer to that question.

Now, if you can automate this when the document opens, then put the
calculating code in a sub and call this sub from the ThisDocument_Open and
ThisDocument_New Subs. Put the result of the calculation in either a
document variable (Look up "Variables" in the VBA help) or a custom document
property.

If you need to let the user run the calculation at a moment of their
choosing, you will need something to make it happen (a button, a key
combination, etc.)

Then, use a DOCVARIABLE or DOCPROPERRTY field with the other field you
mentioned.


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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

Top