Замена текста в MS Word


/ Published in: Delphi
Save to your folder(s)



Copy this code and paste it in your HTML
  1. //Объявление
  2. function SimpleReplace(Tag: string; New:string):boolean;
  3.  
  4. //Описание
  5. //Процедура поиска и замены простых строк//////////////////////////////////////////////////
  6. function TForm1.SimpleReplace(Tag: string; New:string):boolean;
  7. begin
  8. SimpleReplace:=true;
  9. try
  10. MsWord.Selection.End:=0;
  11. MsWord.Selection.Start:=0;
  12. MsWord.Selection.Find.Forward:=true;
  13. MsWord.Selection.Find.Text:= Tag;
  14. if MsWord.Selection.Find.Execute then begin
  15. MsWord.Selection.Delete;
  16. MsWord.Selection.InsertAfter(New);
  17. SimpleReplace(Tag, New);
  18. end else SimpleReplace:=false; //if
  19. except
  20. SimpleReplace:=false;
  21. end;//try
  22. end;
  23. //End SimpleReplace//////////////////////////////////////////////////////////////
  24.  
  25. //Реализация
  26. Var="Text_To_Past";
  27. SimpleReplace('text_to_replace', Var);//Замена текста

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.