有关WORD的操作----如何查找替换。(100分)

冰封

Unregistered / Unconfirmed
GUEST, unregistred user!
有关WORD的操作----如何查找替换。
如果要在一个文章中查找并替换要怎么写?
例如要将文章中的所有test换成ts,要怎么写。
如果ts的值是动态的能实现吗?如第一个找到的test替换为ts1,第二个找到的为ts2,依次类推。
还有就是常量wdReplaceAll和wdFindContinue DELPHI里并没有,它们值是多少?
 
http://www.djpate.freeserve.co.uk/D5Word.zip
 
在 word 里,进行 VBA,
写 上:
msgbox wdReplaceAll
执行一下,就知道了。
 
没人知道吗?
我根据vbawrd上写的程序总是达不到想要的结果。
谁给个程序范例啊?
 
wdReplaceAll 2
wdFindContinue 1
 
在word新建一个宏
执行你要的操作
再用vba打开宏
代码就都出来了。
 
给我一段程序好吗?
在程序中实现在WORD中的查找替换。
例如要将文章中的所有test换成ts,要怎么写。
 
procedure TForm1.replaceClick(Sender: TObject);
var
SearchText, ReplaceText, All: OleVariant;
findtext, matchcase, matchwholeword, matchwildcards, matchsoundslike,
matchallwordforms, forward, wrap, format, replacewith, replace,
matchkashida,matchdiacritics,matchalefhamza,matchcontrol: olevariant;
begin
findtext := 'test';
matchcase := false;
matchwholeword := true;
matchwildcards := false;
matchsoundslike := false;
matchallwordforms := false;
forward := true;
wrap := wdfindcontinue;
format := false;
replacewith := 'ts';
replace := true;//wdReplaceAll;
worddocument1.range.find.execute( findtext, matchcase, matchwholeword,matchwildcards,
matchsoundslike, matchallwordforms,forward,wrap,
format, replacewith, replace,matchkashida,
matchdiacritics,matchalefhamza,matchcontrol );
end;
 
re linsb:
执行的结果还是和我原先的一样。
例如有文章内容为test test1 test2 test。
程序执行完后的结果是ts test1 test2 ts。
中间两个test不会被替换。
可是如果是单纯的在word中做替换操作却能够替换全部的test,得出“ts ts1 ts2 ts”这样的结果。
你能不能让程序做的替换和word里的一样?
 
replace := wdReplaceAll;
 
顶部