我有這個 VBA 代碼,它通過拆分器 (///) 將 word 檔案拆分為多個檔案,
Sub SplitNotes(delim As String, strFilename As String)
Dim doc As Document
Dim arrNotes
Dim I As Long
Dim X As Long
Dim Response As Integer
arrNotes = Split(ActiveDocument.Range, delim)
Response = MsgBox("This will split the document into " & UBound(arrNotes) 1 & " sections.Do you wish to proceed?", 4)
If Response = 7 Then Exit Sub
For I = LBound(arrNotes) To UBound(arrNotes)
If Trim(arrNotes(I)) <> "" Then
X = X 1
Set doc = Documents.Add
doc.Range = arrNotes(I)
doc.SaveAs ThisDocument.Path & "\" & strFilename & Format(X, "000")
doc.Close True
End If
Next I
End Sub
Sub test()
'delimiter & filename
SplitNotes "///", "Notes "
End Sub
這會將拆分的檔案保存到(.Docx),我怎樣才能將它們保存到(.Rtf)呢?
uj5u.com熱心網友回復:
您可以使用wdFormatRTF保存為 RTF 格式,即
doc.SaveAs2 ThisDocument.Path & "\" & strFilename & Format(X, "000"), FileFormat:=wdFormatRTF
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/411974.html
標籤:
上一篇:我怎樣才能使一個范圍的平均值?
下一篇:在VBA中移動檔案
