週四,三月28 2024
  2 回复
  1.2K訪問
0
投票
復原
嗨,
根據這篇文章
https://www.extendoffice.com/documents/word/5415-split-word-document-every-x-pages.html#a1
拜託,我想要同樣的想法,但有字數
所以我想在同一個資料夾中每14000字分割一個word文檔。
謝謝
0
投票
復原
你好,

我們一定會考慮您的建議,並將其納入該功能的未來版本中!感謝您的寶貴意見!

而且,我已經使用 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


如果您遇到任何問題或還有什麼我可以幫助您的,請告訴我。

阿曼達
1個月前
·
#8585
0
投票
復原
感謝您的回覆阿曼達 :)
我運行了VBA程式碼,但花了很長時間沒有任何結果(無回應)
儘管我有一台配備 16GB RAM、256GB M.2 NVMe SSD 和 1TB HDD 的筆記型電腦,但 Word 會掛起並崩潰,風扇聲音過大。
謝謝
  • 頁:
  • 1
有沒有為這個職位尚未作出回复。