rice" intArrayY=2
Case "quantity" intArrayY=3
End Select
IntArrayX = strRight
If strOkay <> "N" Then
TheArray(intArrayY, intArrayX) = strValue
End If
End If
Next
%>
Now we are ready to begin creating the document. We start by setting t
he Microsoft Word Document object RANGE using our variable, rngCurrent
, to the active document (just in case the user has a different docum
ent also open). Then we specify the table size by specifying its locat
ion ( rngCurrent ) and the number of rows and columns it needs.
<%
Set rngCurrent = objWordDoc.Application.ActiveDocument.Content
Set tabCurrent = ObjWordDoc.Application.ActiveDocument.Tables.Add
rngCurrent,intNumrows,4)
%>
Having created the document with the table, we now begin populating th
e table with data. First we point to the first row ( tabRow=1 ), then
begin a loop that will run through each row. We insert a line feed [ C
hr(10) ] at the end of each row to put some white space between rows.
Finally, we increment our row counter, output the dollar values with "
FormatCurrency" to ensure use of dollar signs, commas and decimal plac
es. Right justification of dollar amounts is handled by setting the co
lumn in question to " ParagraphAlignment=2 ". I won''t tell you how muc
h of a pain it was to discover how to do that! Suffice it to say that
it is easier and better documented in VBA, which is not at all like wh
at is required in VBScript.
<%
For j = 1 to intTableRows
ObjWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Borders.E
nable=False
objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(1).
Range.InsertAfter theArray(1,j)
objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(2).
Range.InsertAfter theArray(2,j)
objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(3).
Range.InsertAfter FormatCurrency(theArray(3,j))
objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(4).
Range.InsertAfter theArray(4,j)
objWordDoc.Application.ActiveDocument.Tables(1).Rows(tabRow).Cells(4).
Range.InsertAfter Chr(10)
objWordDoc.Applicatoin.ActiveDocument.Tables(1).Rows(tabRow).Cells(3).
Range.ParagraphFormat.alignment=2
tabRow = tabRow + 1
Next
%>
Finally, we finish up our docu