vb6合并office2007中的word文档
C:\abc\中有1.docx,2.docx,3.docx.....30.docx如何把它们合并到一个新的文档中?试试这个,两个文件合并为新文件。
程序代码: Dim wApp As Word.Application
Dim wDoc As Word.Document
Private Sub Command1_Click()
Merge "c:\1.docx", "c:\2.docx", wApp
Form1.Caption = "OK"
End Sub
Private Sub Form_Load()
Set wApp = New Word.Application
End Sub
Function Merge(ByVal sFirstFile As String, ByVal sSecondFile As String, ByRef wrdapp As Word.Application) As Boolean
Dim docNew As Word.Document
'open the main document
Set docNew = wrdapp.Documents.Open(sSecondFile)
'insert the coversheet
wrdapp.Selection.InsertFile FileName:=sFirstFile, Range:="", ConfirmConversions:=False, Link:=False, Attachment:=False
'set position to first page/coversheet
wrdapp.Selection.MoveUp Unit:=wdScreen, Count:=1
'force header/footer to begin on 2nd page
With wrdapp.Selection.PageSetup
.DifferentFirstPageHeaderFooter = True
End With
'save the document
docNew.SaveAs "C:\NewFile.docx"
End Function







