That is exactly what the code does when I run it.
Starting with a document containing:
SPR¶
L 6:0:1¶
R 8:0:3¶
F 1:0:12¶
SPR¶
R 22:10:30¶
F 17:10:21¶
SPR¶
L 12:19:1¶
F 9:11:7¶
SPR¶
F 0:0:0¶
after running the macro, I get
SPR¶
L 6:0:1¶
R 8:0:3¶
F 1:0:12¶
SPR¶
L 0:0:0¶
R 22:10:30¶
F 17:10:21¶
SPR¶
L 12:19:1¶
R 0:0:0¶
F 9:11:7¶
SPR¶
L 0:0:0¶
R 0:0:0¶
F 0:0:0¶
Are you sure that each item is in a separate paragraph as indicated by the ¶
that I have inserted above.
--
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
"Steved"
news:A8709075-3A8E-429B-A397-463E85D8C9A6@microsoft.com...
> Hello Doug from Steved
> Thankyou
>
> Doug Please could I have in example 2 a input off "L 0:0:0" above the R
> 22:10:30 and in example 4 an input off "L 0:0:0" and "R 0:0:0" inbetween
> SPR
> and F 0:0:0
>
> In Example 3 it is inputing "R 0:0:0" after the L 12:19:1 As per your
> coding
> and I Thankyou.
>
> Example 1 Example 2 Example 3 Example 4
> SPR SPR SPR SPR
> L 6:0:1 R 22:10:30 L 12:19:1 F 0:0:0
> R 8:0:3 F 17:10:21 F 9:11:7
> F 1:0:12
>
>
>
>
>
> "Doug Robbins - Word MVP" wrote:
>
>> Use
>>
>> Dim myrange As Range, myrangedup As Range
>> Selection.HomeKey wdStory
>> Selection.Find.ClearFormatting
>> With Selection.Find
>> Do While .Execute(findText:="F [0-9]{1,}:[0-9]{1,}:[0-9]{1,}",
>> Forward:=True, _
>> MatchWildcards:=True, MatchCase:=True, Wrap:=wdFindStop) =
>> True
>> Set myrange = Selection.Range
>> Selection.Collapse wdCollapseEnd
>> Set myrangedup = myrange.Duplicate
>> myrangedup.start = myrangedup.start - 1
>> myrangedup.Collapse wdCollapseStart
>> If Left(myrangedup.Paragraphs(1).Range.Text, 1) <> "R" Then
>> myrange.InsertBefore "R 0:0:0" & vbCr
>> End If
>> Loop
>> End With
>> Selection.HomeKey wdStory
>> Selection.Find.ClearFormatting
>> With Selection.Find
>> Do While .Execute(findText:="R [0-9]{1,}:[0-9]{1,}:[0-9]{1,}",
>> Forward:=True, _
>> MatchWildcards:=True, MatchCase:=True, Wrap:=wdFindStop) =
>> True
>> Set myrange = Selection.Range
>> Selection.Collapse wdCollapseEnd
>> Set myrangedup = myrange.Duplicate
>> myrangedup.start = myrangedup.start - 1
>> myrangedup.Collapse wdCollapseStart
>> If Left(myrangedup.Paragraphs(1).Range.Text, 1) <> "L" Then
>> myrange.InsertBefore "L 0:0:0" & vbCr
>> End If
>> Loop
>> End With
>>
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "Steved"
>> news:921E0BA8-0CEF-429F-98FF-D258F6D3E95F@microsoft.com...
>> > Hello from Steved
>> >
>> > The below I would like the macro to ignore but it inputs L 0:0:0 and R
>> > 0:0:0
>> > Please how do I tell the macro that Example is right and move onto the
>> > next
>> > and so on, now if eample 2 is found then input L 0:0:0 above the R
>> > 22:10:30
>> > and in Example 3 input R 0:0:0 below the L 12:19:1 and finally in
>> > Example
>> > 4
>> > input L 0:0:0 and L 0:0:0 The macro is below the Examples. Thankyou.
>> > Example 1 Example 2 Example 3 Example 4
>> > SPR SPR SPR SPR
>> > L 6:0:1 R 22:10:30 L 12:19:1 F 0:0:0
>> > R 8:0:3 F 17:10:21 F 9:11:7
>> > F 1:0:12
>> >
>> > Sub Main1()
>> >
>> > Dim aDoc As Document
>> > Dim SearchRng As Range
>> > Dim AllRng As Range
>> >
>> > Set aDoc = ActiveDocument
>> >
>> > Set AllRng = ActiveDocument.Range
>> > Set SearchRng = AllRng.Duplicate
>> >
>> > Do
>> > With SearchRng.Find
>> > .ClearFormatting
>> > .Text = "F [0-9]:[0-9]:[0-9]"
>> > .Forward = True
>> > .Wrap = wdFindStop
>> > .MatchWildcards = True
>> > .Execute
>> > End With
>> >
>> > If Not SearchRng.Find.Found Then Exit Do
>> >
>> > SearchRng.MoveStart wdParagraph, -3
>> > SearchRng.MoveEnd wdParagraph, -3
>> > SearchRng.Select
>> > 'Stop
>> > If Left(SearchRng, 1) = "S" Then
>> > SearchRng.InsertAfter "L 0:0:0" & vbCr & "R 0:0:0" & vbCr
>> > SearchRng.MoveStart wdParagraph, 3
>> > Else
>> > If Left(SearchRng, 1) = "L" Then
>> > SearchRng.InsertAfter "R [0-9]:[0-9]:[0-9]" & vbCr
>> > SearchRng.MoveStart wdParagraph, 3
>> > Else
>> > If Left(SearchRng, 1) = "R" Then
>> > SearchRng.InsertBefore "L [0-0]:[0-9]:[0-9]" & vbCr
>> > SearchRng.MoveStart wdParagraph, 3
>> > End If
>> > End If
>> > End If
>> > SearchRng.End = AllRng.End
>> > Loop Until Not SearchRng.Find.Found
>> >
>> > End Sub
>> >
>>
>>
>>