I'd do something like this -- assumes a lot about the format, but that can be generalized if needed
I wasn't sure what the doc looked like, but the logic to split the long string seems to be Ok.
e.g I didn't know if the doc was one long string in a single para and you wanted to split that into lots of short paragraphs
Option Explicit
'The data starts as one long string with a small header (below would be ABC110)
'and then will always have a H001 to follow.
'Then moves based on the value following the 001.
'So for H001 it is 26 bytes long, C001 it is 29 bytes long,
'S001 is 21 bytes long, and
'A001 is 9 bytes long.
'There is always a space after the length.
Sub breaks()
Dim sIn As String, sWork As String, sOut As String
Dim iLen As Long
sIn = "ABC110H00126 several bytes laterC00129 Another length of dataS00121 more data hereS00121 more data hereA0019 end"
sWork = sIn
iLen = -1
'header assumes header is any length
On Error Resume Next
iLen = InStr(sWork, "00") ' first 0 of 00
On Error GoTo 0
If iLen = 0 Then Exit Sub ' if no 00
iLen = iLen - 2 ' char before H00
sOut = Left(sWork, iLen) & vbCrLf
sWork = Right(sWork, Len(sWork) - iLen)
'data assume format always X000nn where len of data = nn
Do While Len(sWork) > 0
iLen = CLng(Mid(sWork, 5, 2)) ' the 26 in H00126
sOut = sOut & Left(sWork, iLen) & vbCrLf
sWork = Right(sWork, Len(sWork) - iLen)
Loop
MsgBox sOut
End Sub
This is an attempt to do it within a word doc. Select the long text and run the macro and see if it close for you
Option Explicit
Sub breaks_doc()
Dim sIn As String, sWork As String
Dim iLen As Long
sIn = Selection.Text
Selection.Delete
sWork = sIn
iLen = -1
'header assumes header is any length
On Error Resume Next
iLen = InStr(sWork, "00") ' first 0 of 00
On Error GoTo 0
If iLen = 0 Then Exit Sub ' if no 00
iLen = iLen - 2 ' char before H00
Selection.TypeParagraph
Selection.TypeText Text:=Left(sWork, iLen)
Selection.TypeParagraph
sWork = Right(sWork, Len(sWork) - iLen)
'data assume format always X000nn where len of data = nn
Do While Len(sWork) > 1
iLen = CLng(Mid(sWork, 5, 2)) ' the 26 in H00126
Selection.TypeText Text:=Left(sWork, iLen)
Selection.TypeParagraph
sWork = Right(sWork, Len(sWork) - iLen)
Loop
End Sub