你好,
我們一定會考慮您的建議,並將其納入該功能的未來版本中!感謝您的寶貴意見!
而且,我已經使用 Kutools AI Aide 產生了以下 VBA 程式碼並成功測試了它。請隨意嘗試:
注意:請確保在執行此 VBA 腳本之前備份文檔,以防止潛在問題或在必要時恢復任何變更。
Sub SplitDocumentEvery14000Words()
Dim originalDoc As Document
Set originalDoc = ActiveDocument
Dim wordCount As Long
wordCount = 0
Dim docIndex As Integer
docIndex = 1
Dim newDoc As Document
Set newDoc = Documents.Add
Dim originalDocPath As String
originalDocPath = originalDoc.Path
Dim i As Long
For i = 1 To originalDoc.Words.Count
wordCount = wordCount + 1
newDoc.Content.InsertAfter originalDoc.Words(i).Text
' Split and save every 14000 words
If wordCount >= 14000 Then
' Reset word count
wordCount = 0
' Save the document
newDoc.SaveAs2 FileName:=originalDocPath & "\SplitDoc_" & docIndex & ".docx"
' Prepare for next document
docIndex = docIndex + 1
Set newDoc = Documents.Add
End If
Next i
' Save the last document if it has content
If newDoc.Content.Words.Count > 1 Then
newDoc.SaveAs2 FileName:=originalDocPath & "\SplitDoc_" & docIndex & ".docx"
Else
newDoc.Close False
End If
MsgBox "Documents have been split successfully."
End Sub
如果您遇到任何問題或還有什麼我可以幫助您的,請告訴我。
阿曼達