調用Word打印...
運行下列的腳本需要將IE的安全級別設為低,或在中級安全級別下將那個ActiveX控件設為啟用,別忘記了:
<html>
<head>
<title>BuildDocumentbyScript</TITLE>
</HEAD>
<Tableid="myData"border=1align=center>
<Tralign=center>
<Td>產品名稱</Td>
<Td>產品描述</Td>
<Td>產品單價</Td>
<Td>產品等級</Td>
</Tr>
<Tralign=center>
<Td>產品一</Td>
<Td>Thisisatest</Td>
<Tdalign=right>300.50</Td>
<Td>一級</Td>
</Tr>
<Tralign=center>
<Td>產品二</Td>
<Td>Thisisatest</Td>
<Tdalign=right>300.50</Td>
<Td>一級</Td>
</Tr>
<Tralign=center>
<Td>產品三</Td>
<Td>Thisisatest</Td>
<Tdalign=right>300.50</Td>
<Td>一級</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("測試的表格")
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)