I
itfly
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: Tobject);
var MSWord: Variant;
begin
MSWord := CreateOLEObject('Word.Application');//连接Word
MSWord.Documents.Open(FileName:='d:/test.doc', ReadOnly:=True);//打开外部Word文档
MSWord.Visible := 1;//是否显示文件编辑
MSWord.ActiveDocument.Range(Start:=0, End:=0);//开始改变的启止位置
MSWord.ActiveDocument.Range.InsertAfter(Text:='Title');//在Word中增加字符'Title'
MSWord.ActiveDocument.Range.InsertParagraphAfter;
MSWord.ActiveDocument.Range.Font.Name := 'Arial';//字体名称
MSWord.ActiveDocument.Range.Font.Size := 24;//字体大小
end;
显示错误:
[Error] Unit1.pas(29): Undeclared identifier: 'CreateOLEObject'
var MSWord: Variant;
begin
MSWord := CreateOLEObject('Word.Application');//连接Word
MSWord.Documents.Open(FileName:='d:/test.doc', ReadOnly:=True);//打开外部Word文档
MSWord.Visible := 1;//是否显示文件编辑
MSWord.ActiveDocument.Range(Start:=0, End:=0);//开始改变的启止位置
MSWord.ActiveDocument.Range.InsertAfter(Text:='Title');//在Word中增加字符'Title'
MSWord.ActiveDocument.Range.InsertParagraphAfter;
MSWord.ActiveDocument.Range.Font.Name := 'Arial';//字体名称
MSWord.ActiveDocument.Range.Font.Size := 24;//字体大小
end;
显示错误:
[Error] Unit1.pas(29): Undeclared identifier: 'CreateOLEObject'