Call Word to print...
Running the following scripts requires setting IE's security level to low, or setting that ActiveX control to enable at the intermediate security level, don't forget:
<html>
<head>
<title>BuildDocumentbyScript</TITLE>
</HEAD>
<Tableid="myData"border=1align=center>
<Tralign=center>
<Td>Product Name</Td>
<Td>Product Description</Td>
<Td>Product unit price</Td>
<Td>Product Grade</Td>
</Tr>
<Tralign=center>
<Td>Product 1</Td>
<Td>Thisisastest</Td>
<Tdalign=right>300.50</Td>
<Td>Level 1</Td>
</Tr>
<Tralign=center>
<Td>Product 2</Td>
<Td>Thisisastest</Td>
<Tdalign=right>300.50</Td>
<Td>Level 1</Td>
</Tr>
<Tralign=center>
<Td>Product 3</Td>
<Td>Thisisastest</Td>
<Tdalign=right>300.50</Td>
<Td>Level 1</Td>
</Tr>
</Tabld>
<inputtype=buttononclick="vbscript:buildDoc'',4"value="build">
<BODY>
</BODY>
</HTML>
<scriptlanguage="vbscript">
SubbuildDoc(theTemplate,intTableRows)
DimTable1
setTable1=document.all.myData
row=Table1.rows.length
SetobjWordDoc=CreateObject("Word.Document")
ObjWordDoc.Application.Visible=True
DimtheArray(4,4)
'RedimPreservetheArray(4,row)
colnum=Table1.rows(1).cells.length
fori=0torow-1
forj=0tocolnum-1
theArray(j+1,i+1)=Table1.rows(i).cells(j).innerHTML
next
next
intNumrows=4
objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("Table for Testing")
objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("")
objWordDoc.Application.ActiveDocument.Paragraphs.Add.Range.InsertBefore("")
SetrngPara=objWordDoc.Application.ActiveDocument.Paragraphs(1).Range
WithrngPara
.Bold=True
.ParagraphFormat.Alignment=1
.Font.Name="Arial"
.Font.Size=12
EndWith
SetrngCurrent=objWordDoc.Application.ActiveDocument.Paragraphs(3).Range
SettabCurrent=ObjWordDoc.Application.ActiveDocument.Tables.Add(rngCurrent,intNumrows,4)