请问在Delphi如何使用Word中的宏进行查询替代?

解决方案 »

  1.   

    Procedure TForm1.ReplaceData(FindStr, RepStr:string);//利用数据库替换Word字符串函数
    //FindStr:被查找的字符串。RepStr:要替换的字符串。
    var
      MatchCase,MatchWholeWord,find1,rep1,Format,
        MatchWildcards, MatchSoundsLike, MatchAllWordForms, AForward,
        Wrap, Replace : OleVariant;
    begin
        Find1 := FindStr;
        Rep1 := RepStr;
        MatchCase := false;
        MatchWholeWord := true;
        MatchWildcards := false;
        MatchSoundsLike := false;
        MatchAllWordForms := false;
        Format := true;
        AForward := true;
        replace := wdReplaceall;    OleDoc.Range.Find.Execute( find1, MatchCase, MatchWholeWord,
          MatchWildcards, MatchSoundsLike, MatchAllWordForms, AForward,
          Wrap, Format, Rep1, Replace );
    end;