2
2Catman
I need to loop the following code: It is used in a text file that is a
comma-delimited database of journal references. Each reference has 45 fields,
each field is enclosed in quotes and separated by commas. I need to count 11
fields in, add a comma, go the end of the record (a paragraph mark) and then
repeat for the remaining records until the end of the document.
Here is the code I have so far:
Sub Test_find_count()
'
' Test_find_count Macro
' Macro recorded 12/5/2005 by
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""","
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
For X = 1 To 11
Selection.Find.Execute
Next X
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=", "
With Selection.Find
.Text = "^p"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
End Sub
comma-delimited database of journal references. Each reference has 45 fields,
each field is enclosed in quotes and separated by commas. I need to count 11
fields in, add a comma, go the end of the record (a paragraph mark) and then
repeat for the remaining records until the end of the document.
Here is the code I have so far:
Sub Test_find_count()
'
' Test_find_count Macro
' Macro recorded 12/5/2005 by
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""","
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
For X = 1 To 11
Selection.Find.Execute
Next X
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=", "
With Selection.Find
.Text = "^p"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
End Sub