[已解决]求助高手把替换word页眉的vba转换成au3代码
本帖最后由 king8462 于 2016-8-20 21:50 编辑VBA如下:
Sub cs()
Set myRange = ActiveDocument.Sections(1).Headers(2).Range
myRange.Find.Execute findtext:="1zyhao", replacewith:="2016", Replace:=wdReplaceAll
End Sub 自己解决了,代码如下:
#include <Word.au3>
Global $word = ObjCreate("word.application")
$word.visible = True
$Doc =$Word.documents.open (@DesktopDir & "\0001.doc")
Local $context = "1zyhao"
Local $newcontext = "2016"
$Doc.PageSetup.HeaderDistance
$Word.ActiveWindow.ActivePane.View.SeekView = 2
Sleep(100)
With $doc.Application.Selection.range.Find
.ClearFormatting ()
.Replacement.ClearFormatting ()
.Execute($context,0,0,0,0,0,1,1,0,$newcontext,2)
EndWith 大神,
不行啊,只能替换内容,不能替换 页眉 呀 回复 3# pigWoWo
修改下这行代码
$Word.ActiveWindow.ActivePane.View.SeekView = 1 回复 3# pigWoWo
如果替换页脚,修改7、8行代码如下:
$Doc.PageSetup.footerDistance
$Word.ActiveWindow.ActivePane.View.SeekView = 10 可以了 ,膜拜
页:
[1]