求助大神,用delphi7 怎样替换wrod文档所有文本框中相同内容
需要用delphi代码把所有文本框中的“数量”替换成“产品量”unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleServer, Word2000,comobj;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
msword : Variant ;
begin
MSWord:=CreateOLEObject('Word.Application');
MSWord.Documents.Open(FileName:='G:\商务文件.doc');
MSWord.Visible := 1;
msword.selection.find.clearformatting;
msword.selection.find.replacement.clearformatting;
msword.selection.find.text:=‘数量’ ;
msword.selection.find.replacement.text:=‘产品量’ ;
msword.Selection.Find.Execute(Replace:=wdreplaceall);
end;
end.
为什么图上黑色框住的两个“数量”能替换,文本框中的数量就不能替换呢?
求大神指教