Home > OS >  Split Word Document and Save as (.RTF)
Split Word Document and Save as (.RTF)

Time:01-16

I have this VBA code which split word document into multiple documents by the splitter (///),

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

this saves the splitted docs to (.Docx), How can I save them into (.Rtf) instead?

CodePudding user response:

You can use wdFormatRTF to save as RTF format, i.e.

doc.SaveAs2 ThisDocument.Path & "\" & strFilename & Format(X, "000"), FileFormat:=wdFormatRTF
  •  Tags:  
  • Related