在DELPHI中控制WORD中的查找功能,已经找到要查找的内容,能不能移动光标到找到的字符串处?(100)

Z

zjhjp

Unregistered / Unconfirmed
GUEST, unregistred user!
我现在已经实现查找功能,但是在替换时却只能替换到光标位置处,如何将光标定位到我已经找到的地方?部分代码如下: WordApp.Selection.Find.Text:=Edit4.Text; //查询的内容 WordApp.Selection.Find.Replacement.Text:=''; //Edit5.Tex;t; //要替换的内容 WordApp.Selection.Find.Forward := True; // WordApp.Selection.Find.Wrap := 1; //找到一个后继续下一个查询 if WordApp.Selection.Find.Execute(replace:=wdReplaceall) = True then //替换所有找到的内容 //if WordApp.Selection.Find = True then begin //WordApp.Selection.Find.Text:=Memo1.Text; WordApp.Selection.InsertBefore(Memo1.Text); WordApp.Selection.MoveRight; ShowMessage('Find IT'); end else ShowMessage('Sorry,I can''t find it!');其中没有使用替换字符串是因为有些需要替换的内容太长了,直接查找替换不行,报错说字符串太长了,所以采用WordApp.Selection.InsertBefore(Memo1.Text);是希望可以替换更多内容!
 
Z

zjhjp

Unregistered / Unconfirmed
GUEST, unregistred user!
网上找到很多帖子,但基本上都无法实现在selection的内容,比如,要查找的内容是“Test”,要替换的内容是“Replace”,在表格的第一个格子里,现在光标在第二个格子里,执行上述语句时,第一个格子里的内容被清空,第二个格子里的内容变为“Replace”,这不是我所要的结果
 
C

chinasky132

Unregistered / Unconfirmed
GUEST, unregistred user!
肯定可以的.你用VB宏跟踪一下,根据生成的代码修改一下就可以了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
755
import
I
I
回复
0
查看
643
import
I
I
回复
0
查看
545
import
I
顶部