uses comobj, word2000
procedure TForm1.Button2Click(Sender: TObject);
var
WordApp, WordDoc,table: OleVariant;
fileName : string;
begin
WordApp := CreateOleObject('Word.Application');
WordDoc := WordApp.Documents.Add;字體
try
WordDoc.PageSetup.LeftMargin := 0.39*72; // 1 英寸 = 72 磅
WordDoc.PageSetup.RightMargin := 0.39*72; // 1 英寸 = 72 磅
WordDoc.PageSetup.TopMargin := 1*72; // 1 英寸 = 72 磅
WordDoc.PageSetup.BottomMargin := 1*72; // 1 英寸 = 72 磅
WordDoc.PageSetup.PaperSize := wdPaperA4; //A4紙ui
WordApp.Selection.Font.Name := '黑體';
WordApp.Selection.Font.Size := 22;//二號字體 單位:磅
WordApp.Selection.Font.Bold := True;//字體加粗
WordApp.Selection.Font.Color := wdColorBlue;//字體顏色
WordApp.Selection.ParagraphFormat.Alignment := wdAlignParagraphCenter; //段落中文本居中
WordApp.Selection.ParagraphFormat.LineSpacingRule := wdLineSpaceSingle;//單倍行距
WordApp.Selection.TypeText('學生對教師教學工做整體評價');
WordApp.Selection.TypeParagraph;//回車
WordApp.Selection.TypeParagraph;//回車orm
table := WordApp.ActiveDocument.Tables.Add(WordApp.ActiveDocument.Paragraphs.item(3).Range,2,5); //往第三段增長一表格(2行5列)blog
WordApp.Selection.Font.Name := '宋體';
WordApp.Selection.Font.Size := 9;
WordApp.Selection.Font.Bold := False;
WordApp.Selection.Font.Color := wdColorBlack;
table.cell(1,1).VerticalAlignment := wdCellAlignVerticalCenter;
WordApp.Selection.TypeText('教師姓名');ci
table.Cell(1, 1).Merge(table.Cell(2, 1));string
table.Cell(1, 2).Merge(table.Cell(1, 5));it
WordApp.Selection.MoveRight(wdCell,1);
WordApp.Selection.Font.Name := '宋體';
WordApp.Selection.Font.Color := wdColorBlue;
WordApp.Selection.Font.Bold := True;
WordApp.Selection.Font.Size := 12;
WordApp.Selection.TypeText('對 教 師 教 學 工 做 的 綜 合 評 價');
WordApp.Selection.TypeParagraph;
WordApp.Selection.MoveRight(wdCell,1);io
WordApp.Selection.MoveRight(wdCell,1);
WordApp.Selection.Font.Name := '宋體';
WordApp.Selection.Font.Color := wdColorBlack;
WordApp.Selection.Font.Bold := True;
WordApp.Selection.Font.Size := 12;
WordApp.Selection.TypeText('A');
WordApp.Selection.TypeParagraph;
WordApp.Selection.Font.Size := 9;
WordApp.Selection.Font.Bold := False;
WordApp.Selection.TypeText('很是滿意');table
WordApp.Selection.MoveRight(wdCell,1);
WordApp.Selection.Font.Name := '宋體';
WordApp.Selection.Font.Color := wdColorBlack;
WordApp.Selection.Font.Bold := True;
WordApp.Selection.Font.Size := 12;
WordApp.Selection.TypeText('B');
WordApp.Selection.TypeParagraph;
WordApp.Selection.Font.Size := 9;
WordApp.Selection.Font.Bold := False;
WordApp.Selection.TypeText('滿意');file
WordApp.Selection.MoveRight(wdCell,1);
WordApp.Selection.Font.Name := '宋體';
WordApp.Selection.Font.Color := wdColorBlack;
WordApp.Selection.Font.Bold := True;
WordApp.Selection.Font.Size := 12;
WordApp.Selection.TypeText('C');
WordApp.Selection.TypeParagraph;
WordApp.Selection.Font.Size := 9;
WordApp.Selection.Font.Bold := False;
WordApp.Selection.TypeText('基本滿意');
WordApp.Selection.MoveRight(wdCell,1);
WordApp.Selection.Font.Name := '宋體';
WordApp.Selection.Font.Color := wdColorBlack;
WordApp.Selection.Font.Bold := True;
WordApp.Selection.Font.Size := 12;
WordApp.Selection.TypeText('D');
WordApp.Selection.TypeParagraph;
WordApp.Selection.Font.Size := 9;
WordApp.Selection.Font.Bold := False;
WordApp.Selection.TypeText('不滿意');
WordApp.Selection.MoveRight(wdCell,1);//新增一行
WordApp.Selection.Font.Name := '宋體';
WordApp.Selection.Font.Color := wdColorBlack;
WordApp.Selection.Font.Bold := false;
WordApp.Selection.Font.Size := 10.5;
WordApp.Selection.TypeText('教師A');
WordApp.Selection.MoveRight(wdCell,1);
WordApp.Selection.Font.Name := '宋體';
WordApp.Selection.Font.Color := wdColorBlack;
WordApp.Selection.Font.Bold := true;
WordApp.Selection.Font.Size := 12;
WordApp.Selection.TypeText('94');
WordApp.Selection.MoveRight(wdCell,1);
WordApp.Selection.TypeText('6');
WordApp.Selection.MoveRight(wdCell,1);
WordApp.Selection.TypeText('0');
WordApp.Selection.MoveRight(wdCell,1);
WordApp.Selection.TypeText('0');
WordApp.Selection.MoveRight(wdCell,1);//新增一行
WordApp.Selection.Font.Name := '宋體';
WordApp.Selection.Font.Color := wdColorBlack;
WordApp.Selection.Font.Bold := false;
WordApp.Selection.Font.Size := 10.5;
WordApp.Selection.TypeText('教師B');
WordApp.Selection.MoveRight(wdCell,1);
WordApp.Selection.Font.Name := '宋體';
WordApp.Selection.Font.Color := wdColorBlack;
WordApp.Selection.Font.Bold := true;
WordApp.Selection.Font.Size := 12;
WordApp.Selection.TypeText('92');
WordApp.Selection.MoveRight(wdCell,1);
WordApp.Selection.TypeText('8');
WordApp.Selection.MoveRight(wdCell,1);
WordApp.Selection.TypeText('0');
WordApp.Selection.MoveRight(wdCell,1);
WordApp.Selection.TypeText('0');
table.Rows.Alignment := wdAlignRowCenter;//表格居中
table.Borders.Item(wdBorderLeft).LineStyle:=wdLineStyleSingle;
table.Borders.Item(wdBorderRight).LineStyle:=wdLineStyleSingle;
table.Borders.Item(wdBorderTop).LineStyle:=wdLineStyleSingle;
table.Borders.Item(wdBorderBottom).LineStyle:=wdLineStyleSingle;
table.Borders.Item(wdBorderHorizontal).LineStyle:=wdLineStyleSingle;
table.Borders.Item(wdBorderVertical).LineStyle:=wdLineStyleSingle;
fileName := ExtractFilePath(ParamStr(0)) + '整體總評.doc';
WordDoc.saveas(fileName);
finally
WordDoc.Saved := True;
WordDoc.Close;
WordApp.Quit;
end;
ShowMessage('ok');
end;