以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 替换页眉的字符 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=175912) |
-- 作者:水墨青花 -- 发布时间:2022/3/23 17:50:00 -- 替换页眉的字符 老师,您好: 之前的问题中找到了如下代码,想把 页眉中的 “[列名]” 替换为 "编号123”,该如何修改如下代码? 另,标黄的msgbox没有执行。 谢谢! Dim app As New MSWord.Application try Dim fileName = "d:\\test.doc" Dim doc As Object = app.Documents.Open(fileName) app.ActiveWindow.ActivePane.View.SeekView = MSWord.WdSeekView.wdSeekCurrentPageHeader app.ActiveWindow.Selection.WholeStory If app.ActiveWindow.Selection.Find.Execute("[列名]") Then
msgbox("[列名]")
app.ActiveWindow.Selection.TypeText(Text:="编号123") End If app.ActiveWindow.ActivePane.View.SeekView = MSWord.WdSeekView.wdSeekMainDocument app.Visible = True catch ex As exception msgbox(ex.message) app.Quit finally \'app.Quit End try |
-- 作者:水墨青花 -- 发布时间:2022/3/23 18:19:00 -- 我只是想把页眉中的 “[列名]” 替换为 "编号123”,如果把 下面的if判断删掉,就把全部页眉都抹掉了。 所以想解决:1. 如下if搜索不成功 2. 如何只替换想要的字符串,不全部抹掉页眉 If app.ActiveWindow.Selection.Find.Execute("[列名]") Then End If
|
-- 作者:有点蓝 -- 发布时间:2022/3/24 8:34:00 -- http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=173462&skin=0 |