Dynamic update of VBA Macro by DOug

T

Tonto

Doug Robbins - Word MVP was kind enough to write the below macro which
works as required but only updates the fields when I tab past them.

Is there a command that will force the fields to update
dynamicallywithout having to tab past?

Thanks

John

If you were using formfields, with the first formfield having the
bookmark
name of amount1, and the others with the names of amount2, amount3,
amount4,
and you were to run a macro containing the following code on exit from
the
amount1 formfield, it would populate the other formfields with the
required
amounts

With ActiveDocument
Select Case .FormFields("amount1").result
Case 60, 75
.FormFields("amount2").result = .FormFields
("amount1").result /
3
.FormFields("amount3").result = .FormFields
("amount1").result /
3
.FormFields("amount4").result = .FormFields
("amount1").result /
3
Case 50
.FormFields("amount2").result = 20
.FormFields("amount3").result = 20
.FormFields("amount4").result = 10
Case 80
.FormFields("amount2").result = 30
.FormFields("amount3").result = 30
.FormFields("amount4").result = 20
Case Else
MsgBox "You must enter 50, 60, 75 or 80."
.FormFields("amount2").result = 0
.FormFields("amount3").result = 0
.FormFields("amount4").result = 0
End Select
End With


--
Hope this helps.


Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.


Doug Robbins - Word MVP, originally posted via msnews.microsoft.com




(e-mail address removed)...
I would like to automate a letter in Word 2003 so that when a field
value is entered in it, the letter automatically enters three other
vaules elsewhere in the letter?

If then and and


£50 £20 £20 £10


£60 £20 £20 £20


£75 £25 £25 £25


£80 £30 £30 £20


For example if the entered value is £50 then the other three vaulues
will be £20 £20 and £10.


It would also be helpful if you could suggest how to do this with
dates?


I hope you can make a suggestion.


Thanks


John
 
G

Graham Mayor

The fields will not update magically by themselves. You will have to force
an update. Running a macro on exit from a field is as good a way as any. You
could investigate http://www.gmayor.com/formfieldmacros.htm which shows a
method of validating form fields by using onentry macros to other form
fields. You then cannot leave a field until the processing associated with
that field is completed.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
T

Tonto

The fields will not update magically by themselves. You will have to force
an update. Running a macro on exit from a field is as good a way as any. You
could investigatehttp://www.gmayor.com/formfieldmacros.htmwhich shows a
method of validating form fields by using onentry macros to other form
fields. You then cannot leave a field until the processing associated with
that field is completed.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>






- Show quoted text -

Thank you so much Graham.

John
 

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