| 发表于:2007-06-21 08:17:122楼 得分:10 |
sub find_word() set_txt: x_text = inputbox( "请输入要查找的内容 ", "取字符串 ", "试试看 ") if len(x_text) < 1 then exit sub selection.find.clearformatting with selection.find .text = x_text .replacement.text = " " .forward = true .wrap = wdfindcontinue .format = false .matchcase = false .matchwholeword = false .matchbyte = true .matchwildcards = false .matchsoundslike = false .matchallwordforms = false end with selection.find.EXECute if selection.text <> x_text then msgbox "对不起,没有找到符合条件的字符,请重新设置查找条件! ": goto set_txt selection.moveright unit:=wdcharacter, count:=1 set_num: xx = inputbox( "已经找到字符串,请输入你要取得的字符的个数! ", "取字符串 ", 1) if len(xx) < 1 then msgbox "您已经取消了本次操作! ": exit sub if not isnumeric(xx) then msgbox "请输入数字! ": goto set_num selection.moveright unit:=wdcharacter, count:=xx, extend:=wdextend msgbox "为您提取的字符串如下: " & chr(10) & selection.text end sub | | |
|