我需要更改字段的内容,但是这种方式太费时间了,我该怎么办?任何人都能帮助我
procedure TForm1.Button1Click(Sender: TObject);
var
WordApp, WordDocument, Field: OleVariant;
I: Integer;
begin
WordApp := CreateOleObject('Word.Application');
try
WordDocument := WordApp.Documents.Open('C:MyDoc.doc');
if WordDocument.Fields.Count >= 1 then
for I := 1 to WordDocument.Fields.Count do
begin
**Field := WordDocument.Fields.Item(I); // file size:20M,Fields.Count:30, This step takes 3 seconds**
end;
finally
WordApp.Quit;
end;
end;
1条答案
按热度按时间rqcrx0a61#
请使用这里所示的早期绑定which one is better in terms of performance, the early binding or late binding in Delphi COM objects,性能提升非常显著。