J
jasonbarker
I'm having a speed issue that I think could be eliminated with a littl
more knowledge.
I am creating a template form in Microsoft Word. It will be a deposi
ticket with 28 dollar amounts. Each dollar amount is split into tw
text form fields (one for the dollar portion of the amount and th
other for the cents portion of the dollar amount). I have set the nam
of each field (DollarAmt_01 to DollarAmt_28 and CentsAmt_01 t
CentsAmt_28). I have also created a macro that gets run when the focu
exits the text form field for both the dollar and cents fields. Thi
macro cycles through each dollar amount adding them up. Then it cycle
through the cents amount, adding them up, multiplying them by 0.01 an
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 i
taking way too long to process (about 16-18 seconds). Certainly, yo
can tell that I am not experienced with programming in Word. An
suggestions on what I can do to speed things up?
Thanks!
Jaso
more knowledge.
I am creating a template form in Microsoft Word. It will be a deposi
ticket with 28 dollar amounts. Each dollar amount is split into tw
text form fields (one for the dollar portion of the amount and th
other for the cents portion of the dollar amount). I have set the nam
of each field (DollarAmt_01 to DollarAmt_28 and CentsAmt_01 t
CentsAmt_28). I have also created a macro that gets run when the focu
exits the text form field for both the dollar and cents fields. Thi
macro cycles through each dollar amount adding them up. Then it cycle
through the cents amount, adding them up, multiplying them by 0.01 an
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 i
taking way too long to process (about 16-18 seconds). Certainly, yo
can tell that I am not experienced with programming in Word. An
suggestions on what I can do to speed things up?
Thanks!
Jaso