5,139
社区成员
发帖
与我相关
我的任务
分享
Sub test()
Dim fs As Object
Dim a
Dim doc As Document
Dim txtPath, txtName, txtFullName As String
Dim i, docLines As Long
txtPath = "d:\" '文档保存路径
Set doc = Documents("源文档.doc")
Selection.HomeKey Unit:=wdStory
docLines = doc.BuiltInDocumentProperties(wdPropertyLines).Value
For i = 1 To Round(docLines / 9 + 0.5)
Set fs = CreateObject("Scripting.FileSystemObject")
txtFullName = txtPath & "文件" & i & ".txt"
Set a = fs.CreateTextFile(txtFullName, True)
Selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst, Count:=9 * (i - 1) + 1, Name:=""
Selection.MoveDown Unit:=wdLine, Count:=9, Extend:=wdExtend
a.WriteLine (Selection.Text)
a.Close
Set a = Nothing
Set fs = Nothing
Next
End Sub
Sub test()
Dim fs As Object
Dim a
Dim doc As Document
Dim txtPath, txtFullName As String
Dim i, docLines As Long
txtPath = "d:\" '文档保存路径
Set doc = Documents("11.doc")
Selection.HomeKey Unit:=wdStory
docLines = doc.BuiltInDocumentProperties(wdPropertyLines).Value
Set fs = CreateObject("Scripting.FileSystemObject")
For i = 1 To Round(docLines / 9 + 0.5)
txtFullName = txtPath & "文件" & i & ".txt"
Set a = fs.CreateTextFile(txtFullName, True)
Selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst, Count:=9 * (i - 1) + 1, Name:=""
Selection.MoveDown Unit:=wdLine, Count:=9, Extend:=wdExtend
a.WriteLine (Selection.Text)
a.Close
Set a = Nothing
Next
Set fs = Nothing
End Sub