将本vbs文件和a.doc、b.doc保存到同一目录下
测试代码:- ON ERROR RESUME NEXT
- Set WordApp=CreateObject("word.application")
- 'WordAPP.visible=True
- Set FSO=CreateObject("Scripting.FileSystemObject")
- SelfPath=FSO.GetFolder(".").Path & "\"
- FileName1=SelfPath & "a.doc"
- FileName2=SelfPath & "b.doc"
- Set Doc1=WordApp.Documents.Open(FileName1)
- Set Doc2=WordApp.Documents.Open(FileName2)
- TextColumnNum=Doc2.PageSetup.TextColumns.count
- WordApp.selection.WholeStory
- WordApp.selection.Copy
- Doc1.Activate
- WordAPP.selection.move 6
- WordApp.Selection.TypeParagraph
- RangeStart=WordApp.selection.start
- WordApp.selection.Paste
- RangeEnd=Doc1.content.end
- Doc1.Range(RangeStart,RangeEnd).select
- Doc1.Range(RangeStart, RangeStart).InsertBreak 3
- WordApp.selection.Start = WordApp.selection.Start + 1
- Doc1.Range(RangeStart, RangeEnd).InsertBreak 3
- WordApp.Selection.PageSetup.TextColumns.SetCount 1
- Doc1.save
- msgbox "文件合并完成!",vbinformation+vbokonly,"Doc合并"
- Set FSO=nothing
- Set aDoc=nothing
- WordApp.quit
-
复制代码
|