Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.tables
|
|||
|
|||
Formula to calculate sum based on drop down form fieldsin Word...continued
Hi,
In saw this post and it helped me a bit: http://www.eggheadcafe.com/software/...ulate-sum.aspx macropod posted this fomula: {={REF DropDown1}+{REF DropDown2}+{REF DropDown3}+{REF DropDown4}+{REF DropDown5}} BUT, in a large document that contains a TOC it doesn't seem to work very well, almost as if it is not refreshing properly. The I used this macro: Sub AddDropDownResults() Dim dDown1, dDown2 As Integer ' Get value of first drop down form field. dDown1 = Val(ActiveDocument.FormFields ("DropDown1").Result) ' Get value of second drop down form field. dDown2 = Val(ActiveDocument.FormFields("DropDown2").Result) ' Calculate results and place in Text1 form field ActiveDocument.FormFields("Text1").Result = Str(dDown1 + dDown2) End Sub BUT again in a large document it reacts strangely. It basically scroll up & down every page that the macro is running in... Any help would be greatly appreciated Thanks Pedy |
#2
Posted to microsoft.public.word.tables
|
|||
|
|||
Formula to calculate sum based on drop down form fields in Word...
"pedy g" wrote:
Hi, In saw this post and it helped me a bit: http://www.eggheadcafe.com/software/...ulate-sum.aspx macropod posted this fomula: {={REF DropDown1}+{REF DropDown2}+{REF DropDown3}+{REF DropDown4}+{REF DropDown5}} BUT, in a large document that contains a TOC it doesn't seem to work very well, almost as if it is not refreshing properly. Can you describe exactly what happens? The I used this macro: Sub AddDropDownResults() Dim dDown1, dDown2 As Integer ' Get value of first drop down form field. dDown1 = Val(ActiveDocument.FormFields ("DropDown1").Result) ' Get value of second drop down form field. dDown2 = Val(ActiveDocument.FormFields("DropDown2").Result) ' Calculate results and place in Text1 form field ActiveDocument.FormFields("Text1").Result = Str(dDown1 + dDown2) End Sub BUT again in a large document it reacts strangely. It basically scroll up & down every page that the macro is running in... I do not undersatand.. can you elaborate? Again, what is it that you are actually observing? How can the macro "scroll up & down every page" when it is only concerned with three formfields? The size of the document, or the fact that it has a TOC, should not have any impact on this macro. By the way, in VBA Dim dDown1, dDown2 As Integer means that dDown2 is declared as an Integer type and dDown1 is declared as a Variant type. You need: Dim dDown1 As Integer, dDown2 As Integer or Dim dDown1 As Integer Dim dDown2 As Integer Also, the Integer type is not used anymore. I believe the smallest memory unit the compiler will allocate is a Long. So, when you declare Integers, the compiler has to internally convert them to Longs. Might as well declare Longs from the get go! ;-) |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
What is the formula to calculate a percentage in a Word table? | Tables | |||
Formula to calculate sum based on drop down form fields in Word | Tables | |||
how to calculate formula in an office 2007 word table | Tables | |||
change color of cell based upon form drop down selection | Tables | |||
formula to calculate form fill-in fields | Microsoft Word Help |