让word替换标记字符串要使用worddocument.range.find.execute,
这里用delphi替换了< #name> : 
var 
findtext, matchcase, matchwholeword, matchwildcards, matchsoundslike, 
matchallwordforms, forward, wrap, format, replacewith, replace: olevariant; 
begin 
findtext := '< #name> '; 
matchcase := false; 
matchwholeword := true; 
matchwildcards := false; 
matchsoundslike := false; 
matchallwordforms := false; 
forward := true; 
wrap := wdfindcontinue; 
format := false; 
replacewith := 'delphi'; 
replace := true; worddocument.range.find.execute( findtext, matchcase, matchwholeword, 
matchwildcards, matchsoundslike, matchallwordforms, forward, 
wrap, format, replacewith, replace ); end; 

解决方案 »

  1.   

    让word替换标记字符串要使用worddocument.range.find.execute,
    这里用delphi替换了< #name> : 
    var 
    findtext, matchcase, matchwholeword, matchwildcards, matchsoundslike, 
    matchallwordforms, forward, wrap, format, replacewith, replace: olevariant; 
    begin 
    findtext := '< #name> '; 
    matchcase := false; 
    matchwholeword := true; 
    matchwildcards := false; 
    matchsoundslike := false; 
    matchallwordforms := false; 
    forward := true; 
    wrap := wdfindcontinue; 
    format := false; 
    replacewith := 'delphi'; 
    replace := true; worddocument.range.find.execute( findtext, matchcase, matchwholeword, 
    matchwildcards, matchsoundslike, matchallwordforms, forward, 
    wrap, format, replacewith, replace ); end;