如何编程控制自动替换某Word文档中某特定的字符串???(50分)

  • 主题发起人 主题发起人 loxtln
  • 开始时间 开始时间
L

loxtln

Unregistered / Unconfirmed
GUEST, unregistred user!
如何编程控制自动替换某Word文档中某特定的字符串??
 
//Paht 路径,S1待替换的字串,S2替代字串
procedure ReplaceDocStr(Path, S1, S2);
const
wdAlertsNone = $00000000;
wdRepalceAll = $00000002;
var
WordApp, WordDoc: OleVariant;
begin
WordApp := CreateOleObject('Word.Application');
WordApp.DisplayAlerts := wdAlertsNone;
WordApp.Documents.Open(Path);
WordApp.Selection.Find.ClearFormatting;
WordApp.Selection.Find.Replacement.ClearFormatting;
WordApp.Selection.Find.Text := S1;
WordApp.Selection.Find.Replacement.Text := S2;
WordApp.Selection.Find.Forward := True;
WordApp.Selection.Find.Execute(wdRepalceAll);
WordApp.Quit;
WordApp := Unassigned;
end;
 
接受答案了.
 

Similar threads

回复
0
查看
1K
不得闲
D
回复
0
查看
825
DelphiTeacher的专栏
D
D
回复
0
查看
831
DelphiTeacher的专栏
D
D
回复
0
查看
664
DelphiTeacher的专栏
D
后退
顶部