Hello - I need to be able to perform a mathematical calculation from the
result of a drop-down form field. Example: I have a drop down box (NOT
activeX) with 3 values, and I have another form field with a calculation
based on the 'bookmark' name of the drop-down. However, Word does not appear
to calculate anything whichever option I choose from my drop-down box (they
are all numbers).

Any ideas would be very much appreciated! Cheers.

Re: How do I perform calculations from the result of a drop-down formf by Helmut

Helmut
Mon Mar 13 10:52:27 CST 2006

Hi Howard,

>_Any_ ideas would be very much appreciated!

if so then, e.g., like this:

Sub Macro1()
Dim l As Long
With ActiveDocument.Range.FormFields
l = CLng(.Item("Dropdown1").Result)
.Item("text1").Result = Format(l * 2, "0000")
End With
End Sub

Whereby Macro1 is the on-exit-macro of dropdown1.

In Drowdown1 I have "0001", "0002", "0003", "0004",
therefore the conversion to a long number.

In Text1 I'll get "0002", "0004", "0006", "0008".

The formatting is because I want to prevent the formfields
from changing their size.


HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Re: How do I perform calculations from the result of a drop-down f by HowardInformationFirst

HowardInformationFirst
Mon Mar 13 11:26:26 CST 2006

Thankyou for your response, I`ll try it out tomorrow, but it makes sense to me!

Cheers Helmut.

"Helmut Weber" wrote:

> Hi Howard,
>
> >_Any_ ideas would be very much appreciated!
>
> if so then, e.g., like this:
>
> Sub Macro1()
> Dim l As Long
> With ActiveDocument.Range.FormFields
> l = CLng(.Item("Dropdown1").Result)
> .Item("text1").Result = Format(l * 2, "0000")
> End With
> End Sub
>
> Whereby Macro1 is the on-exit-macro of dropdown1.
>
> In Drowdown1 I have "0001", "0002", "0003", "0004",
> therefore the conversion to a long number.
>
> In Text1 I'll get "0002", "0004", "0006", "0008".
>
> The formatting is because I want to prevent the formfields
> from changing their size.
>
>
> HTH
>
> --
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"
>