同意,可以作成域的形式(要输入的地方),然后替换就可以了。这种方式最好(我个人认为)
procedure TForm1.RepalceString;
//让word替换标记字符串要使用worddocument.range.find.execute,这里用delphi替换了<#name>:
var
//一共15个参数
findtext, matchcase, matchwholeword, matchwildcards, matchsoundslike,
matchallwordforms, forward1, wrap, format, replacewith, replace,
MatchKashida, MatchDiacritics, MatchAlefHamza, MatchControl : olevariant; //后四个均为可选项,默认false num : olevariant;
begin
findtext := '数据上报操作说明';
matchcase := false;
matchwholeword := true;
matchwildcards := false;
matchsoundslike := false;
matchallwordforms := false;
forward1 := true;
wrap := wdfindcontinue;
format := false;
replacewith := 'delphi';
replace := true;
MatchKashida := false;
MatchDiacritics := false;
MatchAlefHamza := false;
MatchControl := false;// num := 1;
// WordApplication.Documents.Item(num);
worddocument.ConnectTo(WordApplication.ActiveDocument);
worddocument.range.find.execute( findtext, matchcase, matchwholeword,
matchwildcards, matchsoundslike, matchallwordforms,
forward1, wrap, format, replacewith, replace,
matchKashida, MatchDiacritics,
MatchAlefHamza, MatchControl );
end;
procedure TForm1.RepalceString;
//让word替换标记字符串要使用worddocument.range.find.execute,这里用delphi替换了<#name>:
var
//一共15个参数
findtext, matchcase, matchwholeword, matchwildcards, matchsoundslike,
matchallwordforms, forward1, wrap, format, replacewith, replace,
MatchKashida, MatchDiacritics, MatchAlefHamza, MatchControl : olevariant; //后四个均为可选项,默认false num : olevariant;
begin
findtext := '数据上报操作说明';
matchcase := false;
matchwholeword := true;
matchwildcards := false;
matchsoundslike := false;
matchallwordforms := false;
forward1 := true;
wrap := wdfindcontinue;
format := false;
replacewith := 'delphi';
replace := true;
MatchKashida := false;
MatchDiacritics := false;
MatchAlefHamza := false;
MatchControl := false;// num := 1;
// WordApplication.Documents.Item(num);
worddocument.ConnectTo(WordApplication.ActiveDocument);
worddocument.range.find.execute( findtext, matchcase, matchwholeword,
matchwildcards, matchsoundslike, matchallwordforms,
forward1, wrap, format, replacewith, replace,
matchKashida, MatchDiacritics,
MatchAlefHamza, MatchControl );
end;
解决方案 »
- Server里的Excel组件在帮助里找不到?
- 怎样在关闭程式前退出正在运行的循环呢?急....在线等
- 在将图存入数据库时提示‘invalid blob length',怎么解决?在线等......
- 散分
- 有一个date型的数据和一个time型的数据,请问如何把他们两个合成一个datetime型数据
- 高分求:如何实现联机帮助?(分不够可加)
- 怎样删除动态创建的控件
- 在Delphi中如何刪除Excel中不需要的行和列
- 请问怎样在delphi中调用.vxd文件?(如:vpacket.vxd)
- 数据库查询的小问题
- 我有PASCAL的深厚基础,现在想学Delphi,请大家推荐几本书
- 程序偶尔会提示:access violation at address 00000007,write of address 0043c624
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;