Dim wjm As String = ""
Dim app As New MSWord.Application
Dim fileName1 = "D:\问题\" & wjm & "test2.docx"
Dim fileName2 = "D:\问题\" & wjm & "test3.docx"
FileSys.CopyFile(fileName1 , fileName2 ,True)
Dim doc = app.Documents.Open(fileName2)
dim 总页数 as integer = 4
dim 页数 as integer = 2
For i As Integer = 1 To 总页数 Step 页数
Output.Show("3.1---" & Date.Now)
'doc.Activate
'doc.Sections(1).Range.Select '数字为第几节
'app.ActiveWindow.ActivePane.View.SeekView = MSWord.WdSeekView.wdSeekCurrentPageHeader '插入水印前需更改视图样式为页眉视图
'app.Selection.HeaderFooter.Shapes.AddPicture(ProjectPath & "Images\yemei.png", False, True,-23, -20, 570, 85)
'app.Selection.HeaderFooter.Shapes.AddPicture(ProjectPath & "Images\yejiao.png", False, True,-23, 760, 570, 50)
'app.ActiveWindow.ActivePane.View.SeekView = MSWord.WdSeekView.wdSeekMainDocument '恢复视图样式到原来样式
'Output.Show("3.2---" & Date.Now)
'
Dim range1 = doc.GoTo(MSWord.WdGoToItem.wdGoToPage, MSWord.WdGoToDirection.wdGoToAbsolute, i, Nothing)
Dim range2 = doc.GoTo(MSWord.WdGoToItem.wdGoToPage, MSWord.WdGoToDirection.wdGoToAbsolute, i+页数, Nothing)
Dim ed As Integer = range2.Start - 1
If i +页数 >= 总页数
ed = Doc.Characters.Count
End If
Dim rng As MSWord.Range = doc.Range(Start:=range1.Start, End:=ed)
rng.copy()
Dim doc2 = app.Documents.add
doc2.Content.Paste()
doc2.SaveAs(Filename:=fileName2.replace(".docx", i & "000.docx"))
'app.Documents(fileName2.replace(".docx","." & i & "docx")).ExportAsFixedFormat(fileName2.replace(".docx","." & i & "pdf")), MSWord.WdExportFormat.wdExportFormatPDF)
Output.Show("3.3---" & Date.Now)
Next
app.Quit