Adding Forms Textboxes values

C

Corey ....

New to macros in Word.

I have several Textboxes(forms) on a document.

I want to create a macro to calculate the following:

Textbox43 = textbox36.value + textbox37.value + textbox38.value +
textbox39.value

How would i go about this ?

Corey....
 
G

Graham Mayor

If this is a form, why not calculate the result with a formula field in the
form in place of TextBox43?
eg
{=({ textbox36 } + { textbox37} + { textbox38 } + {textbox39})}
Check the calculate on exit check box in field textbox39's properties.

If you want to do it with a macro then

Sub AddFields()
Dim oFld As FormFields
Dim Val1 As Long
Dim Val2 As Long
Dim Val3 As Long
Dim Val4 As Long
Set oFld = ActiveDocument.FormFields
Val1 = oFld("Textbox36").Result
Val2 = oFld("Textbox37").Result
Val3 = oFld("Textbox38").Result
Val4 = oFld("Textbox39").Result
oFld("Textbox43").Result = Val1 + Val2 + Val3 + Val4
End Sub

Run on exit from Textbox39

Both methods rely on the bookmark names being correct for the fields they
represent.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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