J
jasonbarker
I'm having a speed issue that I think could be eliminated with a little
more knowledge.
I am creating a template form in Microsoft Word with 28 dollar amounts.
Each dollar amount is split into two text form fields (one for the
dollar portion of the amount and the other for the cents portion of the
dollar amount). I have set the name of each field (DollarAmt_01 to
DollarAmt_28 and CentsAmt_01 to CentsAmt_28). I have also created a
macro that gets run when the focus exits the text form field for both
the dollar and cents fields. This macro cycles through each dollar
amount adding them up. Then it cycles through the cents amount, adding
them up, multiplying them by 0.01 and adding the result to the dollar
amount total.
Here's a snippet of my code for the macro:
Sub CalcDepositTicketTotals()
Dim dollarTotal, centsTotal As Double
dollarTotal = 0
dollarTotal = dollarTotal +
Val(ActiveDocument.FormFields("DollarAmt_01").Result)
dollarTotal = dollarTotal +
Val(ActiveDocument.FormFields("DollarAmt_02").Result)
...
dollarTotal = dollarTotal +
Val(ActiveDocument.FormFields("DollarAmt_28").Result)
centsTotal = 0
centsTotal = centsTotal +
Val(ActiveDocument.FormFields("CentsAmt_01").Result)
centsTotal = centsTotal +
Val(ActiveDocument.FormFields("CentsAmt_02").Result)
...
centsTotal = centsTotal +
Val(ActiveDocument.FormFields("CentsAmt_28").Result)
centsTotal = centsTotal * 0.01
dollarTotal = dollarTotal + centsTotal
' US Dollar Amount
ActiveDocument.FormFields("USD_Total").Result = Str(dollarTotal)
End Sub
=====================
I'm sure that I am going about this the wrong way because this is
taking way too long to process (about 16-18 seconds). Certainly, you
can tell that I am not experienced with programming in Word. Any
suggestions on what I can do to speed things up?
Thanks!
Jason
more knowledge.
I am creating a template form in Microsoft Word with 28 dollar amounts.
Each dollar amount is split into two text form fields (one for the
dollar portion of the amount and the other for the cents portion of the
dollar amount). I have set the name of each field (DollarAmt_01 to
DollarAmt_28 and CentsAmt_01 to CentsAmt_28). I have also created a
macro that gets run when the focus exits the text form field for both
the dollar and cents fields. This macro cycles through each dollar
amount adding them up. Then it cycles through the cents amount, adding
them up, multiplying them by 0.01 and adding the result to the dollar
amount total.
Here's a snippet of my code for the macro:
Sub CalcDepositTicketTotals()
Dim dollarTotal, centsTotal As Double
dollarTotal = 0
dollarTotal = dollarTotal +
Val(ActiveDocument.FormFields("DollarAmt_01").Result)
dollarTotal = dollarTotal +
Val(ActiveDocument.FormFields("DollarAmt_02").Result)
...
dollarTotal = dollarTotal +
Val(ActiveDocument.FormFields("DollarAmt_28").Result)
centsTotal = 0
centsTotal = centsTotal +
Val(ActiveDocument.FormFields("CentsAmt_01").Result)
centsTotal = centsTotal +
Val(ActiveDocument.FormFields("CentsAmt_02").Result)
...
centsTotal = centsTotal +
Val(ActiveDocument.FormFields("CentsAmt_28").Result)
centsTotal = centsTotal * 0.01
dollarTotal = dollarTotal + centsTotal
' US Dollar Amount
ActiveDocument.FormFields("USD_Total").Result = Str(dollarTotal)
End Sub
=====================
I'm sure that I am going about this the wrong way because this is
taking way too long to process (about 16-18 seconds). Certainly, you
can tell that I am not experienced with programming in Word. Any
suggestions on what I can do to speed things up?
Thanks!
Jason