以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- word 替换只可以替换一次 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=144127) |
-- 作者:fntfgz -- 发布时间:2019/12/11 15:24:00 -- word 替换只可以替换一次 Dim app As New MSWord.Application try Dim doc = app.Documents.Open("D:\\02collectdata\\课程文章\\wj.doc") app.Selection.Find.Text = "^l" app.Selection.Find.Replacement.ClearFormatting() app.Selection.Find.Replacement.Text = "^p" app.Selection.Find.Execute(Replace:=MSWord.WdReplace.wdReplaceAll) doc.save app.Selection.Find.Text = "^p^p" app.Selection.Find.Replacement.ClearFormatting() app.Selection.Find.Replacement.Text = "^p" app.Selection.Find.Execute(Replace:=MSWord.WdReplace.wdReplaceAll) app.visible = True catch ex As exception msgbox(ex.message) app.Quit finally End try 老师,上面代码,我做了两次替换,但是只是第一次可以成功,如果注释掉任何一个替换都可正常运行,就是两个同时运行时,只运行第一个,老师怎么才可以做多次查找替换
|
-- 作者:有点蓝 -- 发布时间:2019/12/11 15:47:00 -- …… app.Selection.Find.Execute(Replace:=MSWord.WdReplace.wdReplaceAll) app.Selection.Find.Text = "^p^p" app.Selection.Find.Replacement.ClearFormatting() app.Selection.Find.Replacement.Text = "^p" app.Selection.Find.Execute(Replace:=MSWord.WdReplace.wdReplaceAll) doc.save app.visible = True ……
|