Hello from Steve
The below is ignoring the script ".Text = "[a-z]:"" meaning it will not execute.
What is required please to have the above reconize ".Text = "[a-z]:""
Apart from the above it is Working as it was intended.
To me the below is an excellent and brilliant "Loop". Thank you
Sub Jockey()
Do While Selection.Find.Execute = True
Selection.Find.ClearFormatting
With Selection.Find
.Text = "[a-z]:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = True
.MatchWholeWord = True
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=3
With Selection.Find
.Text = "[0-9]{1,} [A-Z]{1,}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = True
.MatchWholeWord = True
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Extend
With Selection.Find
.Text = " "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=2
Selection.Fields.Update
Dim strText As String
strText = Selection.Text
Selection.Collapse Direction:=wdCollapseStart
Selection.HomeKey Unit:=wdStory
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Forward = True
.Wrap = wdFindStop
.MatchCase = True
.MatchWholeWord = True
.Text = strText
.MatchWildcards = False
.Execute
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Find.ClearFormatting
With Selection.Find
.Text = "[0-9]{1,}.[0-9]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=2
Selection.Extend
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "[A-Z] [A-Z]{1,}"
.Replacement.Text = ""
.Forward = False
.Wrap = wdFindStop
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Copy
Selection.HomeKey Unit:=wdLine
With Selection.Find
.Text = "[0-9]{1,} [A-Z]{1,}"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Fields.Update
strText = Selection.Text
Selection.Collapse Direction:=wdCollapseStart
Selection.HomeKey Unit:=wdLine
Selection.MoveDown Unit:=wdLine, Count:=4
With Selection.Find
.Forward = True
.Wrap = wdFindStop
.MatchCase = True
.MatchWholeWord = True
.Text = strText
.MatchWildcards = False
.Execute
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1
With Selection.Find
.Text = " "
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Paste
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.EndKey Unit:=wdLine
Selection.HomeKey Unit:=wdLine
Loop
End Sub