Naidee,
There shouldn't be any lines starting with ".." just "." (or one
period). As for the other error it is most likely do to the text
wrapping in the newsgroup window. In your VBA Editor go to
Tool>Options. Check all of the boxes on the editor tab. Click the
editor format tab and then the "Syntax error text" in the code color
window. Make it red or some other standout color.
Posted here that line is broken up into three segments. When I pasted
from here that separators were not working and I had to reformat it.
From the end of the first line bring the second line up then from the
end of the second line bring the third line up. Romove the _ and then
delete and readd the space between the comma and next charater. This
should clear up the error and the code will run.
Here is the code again. I just confirmed it works without error:
Sub ScratchMarco()
Dim oPara As Paragraph
Dim myRange As Range
Dim oTbl As Table
For Each oPara In ActiveDocument.Paragraphs
Set myRange = oPara.Range
myRange.MoveEnd Unit:=wdCharacter, Count:=-1
On Error Resume Next
myRange.ConvertToTable Separator:=wdSeparateByCommas, NumColumns:=1
Next
For Each oTbl In ActiveDocument.Tables
oTbl.Sort FieldNumber:="Column 1", _
SortFieldType:=wdSortFieldAlphanumeric, _
SortOrder:=wdSortOrderAscending
oTbl.ConvertToText Separator:=","
Next
Set myRange = ActiveDocument.Range
myRange.Find.ClearFormatting
myRange.Find.Replacement.ClearFormatting
With myRange.Find
..Text = "([!^13])^13([!^13])"
..Replacement.Text = "\1, \2"
..Forward = True
..Wrap = wdFindContinue
..Format = False
..MatchCase = False
..MatchWholeWord = False
..MatchWildcards = True
..MatchSoundsLike = False
..MatchAllWordForms = False
End With
myRange.Find.Execute Replace:=wdReplaceAll
myRange.Find.ClearFormatting
myRange.Find.Replacement.ClearFormatting
With myRange.Find
..Text = "^13{2,}"
..Replacement.Text = "^13"
..Forward = True
..Wrap = wdFindContinue
..Format = False
..MatchCase = False
..MatchWholeWord = False
..MatchWildcards = True
..MatchSoundsLike = False
..MatchAllWordForms = False
End With
myRange.Find.Execute Replace:=wdReplaceAll
End Sub