复制代码 代码如下:
<script>
function wordcontorl(){
alert("小孟佳的宝贝");
var WordApp=new ActiveXObject("Word.Application");
var wdCharacter=1
var wdOrientLandscape = 1
WordApp.Application.Visible=true; //执行完成之后是否弹出已经生成的word
var myDoc=WordApp.Documents.Add();//创建新的空文档
WordApp.ActiveDocument.PageSetup.Orientation = wdOrientLandscape//页面方向设置为横向
WordApp. Selection.ParagraphFormat.Alignment=1 //1居中对齐,0为居右
WordApp. Selection.Font.Bold=true
WordApp. Selection.Font.Size=20
WordApp. Selection.TypeText("孟佳烧香");
WordApp. Selection.MoveRight(wdCharacter); //光标右移字符
WordApp.Selection.TypeParagraph() //插入段落
WordApp. Selection.Font.Size=12
WordApp. Selection.TypeText("-----朱漪编写"); //分行插入日期
WordApp.Selection.TypeParagraph() //插入段落
var myTable=myDoc.Tables.Add (WordApp.Selection.Range, 8,7) //8行7列的表格
//myTable.Style="网格型"
var aa = "孟佳标题"
var TableRange; //以下为给表格中的单元格赋值
for (i= 0;i<7;i++)
{
with (myTable.Cell(1,i+1).Range)
{
font.Size = 12;
InsertAfter(aa);
ColumnWidth =4
}
}
for (n =0;n<7;n++)
{
for (i =0;i<7 ;i++)
{
with (myTable.Cell(i+2,n+1).Range)
{font.Size = 12;
InsertAfter("孟佳小可爱");
}
}
}
row_count = 0;
col_count = 0
myDoc.Protect(1)
}
wordcontorl()
</script>
每种功能的实现方法有很多,希望各位可以交流不同的思想和方法。可以加QQ412546724。呵呵