I need to split a RTF document based on a delimiter which is done. But it is not dragging over the formatting. I would like to keep my bold fonts and tab spacing. It is currently recording a tab as 5 spaces when in the original document it can be 40 spaces. I'm also not sure the page. Setup will be necessary after a solution is found. Any help would be appreciated. Code below.
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
'Dim arrNotes As Document
arrNotes = Split(ActiveDocument.Range.FormattedText, 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
Dim wd As Word.Application
Set wd = Application
Set doc = wd.Documents.Add
'doc.Range = arrNotes(I)
billz.Range.FormattedText = arrNotes(I)
Dim ZA As Double
ZA = Left(arrNotes(I), 9)
With doc.PageSetup
.Orientation = wdOrientLandscape
.BottomMargin = InchesToPoints(0.17)
.TopMargin = InchesToPoints(0.17)
.LeftMargin = InchesToPoints(0.25)
.RightMargin = InchesToPoints(0.25)
.VerticalAlignment = wdAlignVerticalTop
End With
doc.SaveAs ThisDocument.Path & "\" & ZA & ".doc", (wdFormatOriginalFormatting)
doc.Close True
End If
Next I
End Sub
Sub test()
'delimiter & filename
SplitNotes "EndEntry", "EndEntry"
End Sub
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
'Dim arrNotes As Document
arrNotes = Split(ActiveDocument.Range.FormattedText, 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
Dim wd As Word.Application
Set wd = Application
Set doc = wd.Documents.Add
'doc.Range = arrNotes(I)
billz.Range.FormattedText = arrNotes(I)
Dim ZA As Double
ZA = Left(arrNotes(I), 9)
With doc.PageSetup
.Orientation = wdOrientLandscape
.BottomMargin = InchesToPoints(0.17)
.TopMargin = InchesToPoints(0.17)
.LeftMargin = InchesToPoints(0.25)
.RightMargin = InchesToPoints(0.25)
.VerticalAlignment = wdAlignVerticalTop
End With
doc.SaveAs ThisDocument.Path & "\" & ZA & ".doc", (wdFormatOriginalFormatting)
doc.Close True
End If
Next I
End Sub
Sub test()
'delimiter & filename
SplitNotes "EndEntry", "EndEntry"
End Sub