请帮助:
我有大约400页的大型 RTF 文件。我想根据行数将RTF文件拆分成多个文件。
例如:
我想将每15行拆分成一个新的rtf文件。这可能吗?
我已经设法根据新页面拆分文档,但我需要根据行数拆分它。我以前根据新页面拆分文件的宏是:
Sub BreakOnPage()
' Used to set criteria for moving through the document by page.
Application.Browser.Target = wdBrowsePage
For i = 1 To ActiveDocument.BuiltInDocumentProperties("Number of Pages")
'Select and copy the text to the clipboard.
ActiveDocument.Bookmarks("\page").Range.Copy
' Open new document to paste the content of the clipboard into.
Documents.Add
Selection.Paste
' Removes the break that is copied at the end of the page, if any.
Selection.TypeBackspace
ChangeFileOpenDirectory "C:\"
DocNum = DocNum + 1
ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"
ActiveDocument.Close
' Move the selection to the next page in the document.
Application.Browser.Next
Next i
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
答案 0 :(得分:0)
虽然我不参与iOS编程,但这个vba代码可能对你有所帮助:
Sub SplitDoc()
SplitAfterLines 15
End Sub
Private Sub SplitAfterLines(xLines As Integer)
Dim docCounter As Integer
Dim docPath As String
Dim lineMove As Long
docPath = ActiveDocument.Path
docCounter = 1
Selection.HomeKey wdStory
Do
lineMove = Selection.MoveDown(wdLine, xLines, wdExtend)
If lineMove < xLines Then
ActiveDocument.SaveAs2 docPath & "\Split_" & docCounter & ".doc"
Exit Do
End If
Selection.Cut
Application.Documents.Add
Selection.Paste
ActiveDocument.SaveAs2 docPath & "\Split_" & docCounter & ".doc"
ActiveDocument.Close
docCounter = docCounter + 1
Loop
ActiveDocument.Close
End Sub
虽然我确信有更清洁的方法,但我希望这会帮助你走向你想要的方向......