Work with word document
This example shows, how to run MS Word, open *.doc file and insert some string to this file, save and close document.Don't forget add ComObj in uses chapter.
uses
ComObj;
...
var
Word: Variant;
...
procedure TForm1.Button1Click(Sender: TObject);
begin
Word:=CreateOLEObject('Word.Application');
Word.Visible:=True;
Word.Documents.Open(GetCurrentDir+'/Test.doc');
Word.WordBasic.Insert('Greatis ');
Word.Documents.Save;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Word.Documents.Close;
end;
本文介绍了一种使用Delphi编程语言操作Microsoft Word文档的方法。具体步骤包括:创建Word应用程序实例,使Word可见,打开指定的.doc文件,在文档中插入字符串,保存更改,并关闭文档。示例代码展示了如何通过调用OLE对象实现这一过程。
1087

被折叠的 条评论
为什么被折叠?



