Reputation: 1
I need change fields's content,but this way is take too much time,how can i do? Anyone can help me
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;
Upvotes: 0
Views: 125
Reputation: 579
Please use early binding as shown here which one is better in terms of performance, the early binding or late binding in Delphi COM objects The performance increase is significant.
Upvotes: 1