操作word类,插入表格,分页符,日期,页码,替换,图片
FileName: string); //插入图片 procedure AddPicture(FileName: string); //移到最后 procedure MoveEnd(); //合并 procedure CellsMerge(); constructor Create; destructor Destroy; override; end; //function Myword: TMyWord; implementation //var // FMyWord: TMyWord; {function Myword: TMyWord; begin if FMyWord = nil then begin FMyWord := TMyWord.Create; end; Result := FMyWord; end; } constructor TMyWord.Create(); begin inherited Create; connectword(); // end; procedure TMyWord.connectword(); var B: Boolean; begin B := False; if (FWord = nil) then B := True else begin try FDoc.Activate; except B := True; end; end; if not B then Exit; FWord := TWordApplication.Create(nil); //word对象 FDoc := TWordDocument.Create(nil); //文档对象 FWord.Connect; FDoc.Activate; FWord.Visible := True; end; destructor TMyWord.Destroy; begin // //FDoc.SaveAs(''c:\1.doc''); FDoc.Free; FWord.Disconnect; //退出一定退出word,by yl 2005.2.2 //FWord.Quit; //FWord.Free; inherited Destroy; end; procedure TMyWord.AddReturn(); begin try FWord.Selection.TypeParagraph; except AddReturn(); end; end; procedure TMyWord.SetFont(FontName: string; FontSize: Integer; FontBold: Boolean = False; FontUnderline: Boolean = False); begin try //connectword(); FWord.Selection.Font.Name := FontName; FWord.Selection.Font.Size := FontSize; if FontBold then FWord.Selection.Font.Bold := wdToggle; &nb