解决办法:
Private Sub ParseWordDoc(ByVal Filename As String, ByVal NewFileName As String)
Dim WordApp As Microsoft.Office.Interop.Word.Application = New Microsoft.Office.Interop.Word.Application()
Dim BaseDoc As Microsoft.Office.Interop.Word.Document
Dim DestDoc As Microsoft.Office.Interop.Word.Document
Dim intNumberOfPages As Integer
Dim intNumberOfChars As String
Dim intPage As Integer
Word Constants
Const wdGoToPage = 1
Const wdStory = 6
Const wdExtend = 1
Const wdCharacter = 1
Show WordApp
WordApp.ShowMe()
Load Base Document
BaseDoc = WordApp.Documents.Open(Filename)
BaseDoc.Repaginate()
Loop through pages
intNumberOfPages = BaseDoc.BuiltInDocumentProperties("Number of Pages").value
intNumberOfChars = BaseDoc.BuiltInDocumentProperties("Number of Characters").value
For intPage = 1 To intNumberOfPages
If intPage = intNumberOfPages Then
WordApp.Selection.EndKey(wdStory)
Else
WordApp.Selection.GoTo(wdGoToPage, 2)
Application.DoEvents()
WordApp.Selection.MoveLeft(Unit:=wdCharacter, Count:=1)
End If
Application.DoEvents()
WordApp.Selection.HomeKey(wdStory, wdExtend)
Application.DoEvents()
WordApp.Selection.Copy()
Application.DoEvents()
Create New Document
DestDoc = WordApp.Documents.Add
DestDoc.Activate()
WordApp.Selection.Paste()
DestDoc.SaveAs(NewFileName & intPage.ToString & ".doc")
DestDoc.Close()
DestDoc = Nothing
WordApp.Selection.GoTo(wdGoToPage, 2)
Application.DoEvents()
WordApp.Selection.HomeKey(wdStory, wdExtend)
Application.DoEvents()
WordApp.Selection.Delete()
Application.DoEvents()
Next
BaseDoc.Close(False)
BaseDoc = Nothing
WordApp.Quit()
WordApp = Nothing
End Sub
贷项转入“Jaylin Tap