2
2Catman
I have a comma-delimited word file that needs a lot of formatting. In one
case I have to find the comma delimiter multiple times until I get to the
correct place and then make a change. This is repeated until all the changes
are made for that record. Each record is ended with a paragraph mark. I have
created a macro that will change the first record correctly, and if I keep
running the macro it keeps correcting on down through the document. However,
I haven't been able to create a Do...Loop statement that works correctly to
do it automatically.
Here is the macro I have so far...
Sub Test_find_count()
'
' Test_find_count Macro
' Macro recorded 12/5/2005 by John Walsh
'
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 12
Selection.Find.Execute
Next X
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=", "
For X = 1 To 12
Selection.Find.Execute
Next X
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:="Volume "
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=", "
For X = 1 To 2
Selection.Find.Execute
Next X
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:="Issue "
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=", "
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:="pp. "
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
case I have to find the comma delimiter multiple times until I get to the
correct place and then make a change. This is repeated until all the changes
are made for that record. Each record is ended with a paragraph mark. I have
created a macro that will change the first record correctly, and if I keep
running the macro it keeps correcting on down through the document. However,
I haven't been able to create a Do...Loop statement that works correctly to
do it automatically.
Here is the macro I have so far...
Sub Test_find_count()
'
' Test_find_count Macro
' Macro recorded 12/5/2005 by John Walsh
'
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 12
Selection.Find.Execute
Next X
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=", "
For X = 1 To 12
Selection.Find.Execute
Next X
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:="Volume "
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=", "
For X = 1 To 2
Selection.Find.Execute
Next X
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:="Issue "
Selection.Find.Execute
Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.TypeText Text:=", "
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:="pp. "
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