T
TBotsko
I've got a number of MS Word forms that are initially
filled with information from a SQL Script. I want to
perform calculations on some of the keyfields filled in
from the SQL script and then put those results into other
bookmarks in the form.
I've got code that allows me to do the proper calculations
in a table, but the form doesn't lend itself to having
tables in it.
Dim r As Row
Dim strReturnDate As String
Dim strOrder_Amount As String
For Each r In ActiveDocument.Tables(1).Rows
If Not r.IsFirst Then
' this gets you the cell content
strReturnDate = r.Cells(1).Range.Text
strOrder_Amount = r.Cells(3).Range.Text
' but you have to get rid of the end of cell
marker)
strReturnDate = Left(strReturnDate, Len
(strReturnDate) - 1)
strOrder_Amount = Left(strOrder_Amount, Len
(strOrder_Amount) - 1)
r.Cells(2).Range.Text = CStr(DateAdd("w", -30,
CDate(strReturnDate)))
cOrder_Amount = CInt(strOrder_Amount)
r.Cells(4).Range.Text = CStr(cOrder_Amount / 10)
End If
Next
Any suggestions are greatly appreciated.
filled with information from a SQL Script. I want to
perform calculations on some of the keyfields filled in
from the SQL script and then put those results into other
bookmarks in the form.
I've got code that allows me to do the proper calculations
in a table, but the form doesn't lend itself to having
tables in it.
Dim r As Row
Dim strReturnDate As String
Dim strOrder_Amount As String
For Each r In ActiveDocument.Tables(1).Rows
If Not r.IsFirst Then
' this gets you the cell content
strReturnDate = r.Cells(1).Range.Text
strOrder_Amount = r.Cells(3).Range.Text
' but you have to get rid of the end of cell
marker)
strReturnDate = Left(strReturnDate, Len
(strReturnDate) - 1)
strOrder_Amount = Left(strOrder_Amount, Len
(strOrder_Amount) - 1)
r.Cells(2).Range.Text = CStr(DateAdd("w", -30,
CDate(strReturnDate)))
cOrder_Amount = CInt(strOrder_Amount)
r.Cells(4).Range.Text = CStr(cOrder_Amount / 10)
End If
Next
Any suggestions are greatly appreciated.