VBA 关于检测是不是有指定字符

fieldset{padding:10px;}

VBA 关于检测是否有指定字符。整个过程:光标到达指定字符,并向右移2个字符。再向右选取每一个字符,有指定的字符,则光标再向右移动4个字符,同时退出for。问题:怎么没有移动光标呢?谢谢各位看官,本人没有办法了,请求帮助。OptionExplicitDimiAsIntegerPrivateSubCommand1_Click()DimwordAppDimWordSetwordApp=CreateObject(“Word.Application”)SetWord=wordApp.Documents.Open(App.Path&”\施工收费核定清单(表4)(模板).doc”)wordApp.Visible=TrueDimrngTenCharactersAsRange’设置wordApp.Selection.MoveRightUnit:=wdCharacter,Count:=2’则光标向右移动2个字符Fori=0To100’从第三个字开始,至第100个字wordApp.Selection.MoveRightUnit:=wdCharacter,Count:=1’光标向右移动一个字符SetrngTenCharacters=wordApp.ActiveDocument.Range(Start:=i,End:=i+1)’每次选取中一个字符’MsgBoxrngTenCharacters’显示该字符是什么字符IfrngTenCharacters=”标”Then’如果是“标”wordApp.Selection.MoveRightUnit:=wdCharacter,Count:=4’则光标向右移动四个字符ExitFor’退出for循环EndIfNextiwordApp.Selection.TypeTextText:=”一草一木”‘退出后再写入字符EndSub——解决方案——————————————————–Fori=424To451’从第0个字开始,至第500个字wdApp.ActiveDocument.Range(start:=i,End:=i+6).Select’显示该字符是什么字符IfwdApp.ActiveDocument.Range(start:=i,End:=i+6).Text=”联系电话:”ThenwdApp.Selection.MoveRightUnit:=wdCharacter,Count:=1’光标向右移动一个字符ExitForEndIfNextiwdApp.Selection.TypeTextText:=Text58.TextCallCharNumber(Trim(Text58.Text))IfotherChar=0ThenChinaEn=Val(NumberChar)’-1ElseChinaEn=Round(3*Val(otherChar)/2)+Val(NumberChar)+1EndIfwdApp.Selection.MoveRightUnit:=wdCharacter,Count:=0’光标至Text尾Fori=1ToChinaEnwdApp.Selection.DeleteUnit:=wdCharacter,Count:=1’删除一格Nexti山不厌高,水不厌深。

VBA 关于检测是不是有指定字符

相关文章:

你感兴趣的文章:

标签云: