Search and Replace Days or Months

J

Johann Swart

I apologise if this is not the correct category for placing these questions;
none of the others seem appropriate.

Is it possible in Word (2002 on Win2K) to search for the abbreviation of any
month (Jan to Dec) and replace it with the full name, e.g. January, or
December. LIkewise for the days of the week, i.e. Sun to Sat, and replace it
with Sunday, Saturday.

Also, is it possible by ways of a macro or otherwise to search for; e.g
"September 29, 2006" and replace it with "29 September 2006"?

If these are only possible by means of macros, would you be so kind to
provide the macro as I am VB illiterate.

Thank you
Johann
 
J

Johann Swart

Hi Graham,
Thanks for your response.
I visited your site but did not find anything specifically that addresses my
particular situation. Or are you saying that one should do a separate seach
and replace for each month name and/or day name?
Regards
Johann
 
G

Graham Mayor

Unless they are date fields, you will have to search each short version and
replace with the longer version. The transposed dates are a different issue
and again you will have to search each combination using a wildcard search -
hence the link. The following macros will do both tasks
http://www.gmayor.com/installing_macro.htm

Sub ReplaceList()
Dim vFindText As Variant
Dim vReplText As Variant
Dim i As Long
vFindText = Array("Jan", "Feb", "Mar", "Apr", "May", _
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", _
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
vReplText = Array("January", "February", "March", _
"April", "May", "June", "July", "August", "September", _
"October", "November", "December", "Monday", "Tuesday", _
"Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = vReplText(i)
.Execute replace:=wdReplaceAll
Next i
End With
End Sub

Sub TransposeDates()
Dim vFindText As Variant
Dim i As Long
vFindText = Array("(January) ([0-9]{1,2}), ([0-9]{4})", _
"(February) ([0-9]{1,2}), ([0-9]{4})", _
"(March) ([0-9]{1,2}), ([0-9]{4})", _
"(April) ([0-9]{1,2}), ([0-9]{4})", _
"(May) ([0-9]{1,2}), ([0-9]{4})", _
"(June) ([0-9]{1,2}), ([0-9]{4})", _
"(July) ([0-9]{1,2}), ([0-9]{4})", _
"(August) ([0-9]{1,2}), ([0-9]{4})", _
"(September) ([0-9]{1,2}), ([0-9]{4})", _
"(October) ([0-9]{1,2}), ([0-9]{4})", _
"(November) ([0-9]{1,2}), ([0-9]{4})", _
"(December) ([0-9]{1,2}), ([0-9]{4})")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = "\2 \1 \3"
.Execute replace:=wdReplaceAll
Next i
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Johann Swart

Hi Graham,
Thank you very much.
I have installed both, and the first one (Replace List) works 100%. However,
the second one (Transpose Dates) *seems* to have glitch. The debugger
highlights the fourth last line (.Execute Replace:=wdReplaceAll). Could it
possibly be as a result of my Windows Regional Settings which has a decimal
comma, and a semicolon as a list separator?

Graham Mayor said:
Unless they are date fields, you will have to search each short version and
replace with the longer version. The transposed dates are a different issue
and again you will have to search each combination using a wildcard search -
hence the link. The following macros will do both tasks
http://www.gmayor.com/installing_macro.htm

Sub ReplaceList()
Dim vFindText As Variant
Dim vReplText As Variant
Dim i As Long
vFindText = Array("Jan", "Feb", "Mar", "Apr", "May", _
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", _
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
vReplText = Array("January", "February", "March", _
"April", "May", "June", "July", "August", "September", _
"October", "November", "December", "Monday", "Tuesday", _
"Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = vReplText(i)
.Execute replace:=wdReplaceAll
Next i
End With
End Sub

Sub TransposeDates()
Dim vFindText As Variant
Dim i As Long
vFindText = Array("(January) ([0-9]{1,2}), ([0-9]{4})", _
"(February) ([0-9]{1,2}), ([0-9]{4})", _
"(March) ([0-9]{1,2}), ([0-9]{4})", _
"(April) ([0-9]{1,2}), ([0-9]{4})", _
"(May) ([0-9]{1,2}), ([0-9]{4})", _
"(June) ([0-9]{1,2}), ([0-9]{4})", _
"(July) ([0-9]{1,2}), ([0-9]{4})", _
"(August) ([0-9]{1,2}), ([0-9]{4})", _
"(September) ([0-9]{1,2}), ([0-9]{4})", _
"(October) ([0-9]{1,2}), ([0-9]{4})", _
"(November) ([0-9]{1,2}), ([0-9]{4})", _
"(December) ([0-9]{1,2}), ([0-9]{4})")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = "\2 \1 \3"
.Execute replace:=wdReplaceAll
Next i
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Johann said:
Hi Graham,
Thanks for your response.
I visited your site but did not find anything specifically that
addresses my particular situation. Or are you saying that one should
do a separate seach and replace for each month name and/or day name?
Regards
Johann
 
G

Graham Mayor

Yes - it is the regional settings that are screwing it up :(
The problem is the comma separator between the 1&2
([0-9]{1,2})
in each date. Change that for whatever you use locally and it should work.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Johann said:
Hi Graham,
Thank you very much.
I have installed both, and the first one (Replace List) works 100%.
However, the second one (Transpose Dates) *seems* to have glitch. The
debugger highlights the fourth last line (.Execute
Replace:=wdReplaceAll). Could it possibly be as a result of my
Windows Regional Settings which has a decimal comma, and a semicolon
as a list separator?

Graham Mayor said:
Unless they are date fields, you will have to search each short
version and replace with the longer version. The transposed dates
are a different issue and again you will have to search each
combination using a wildcard search - hence the link. The following
macros will do both tasks http://www.gmayor.com/installing_macro.htm

Sub ReplaceList()
Dim vFindText As Variant
Dim vReplText As Variant
Dim i As Long
vFindText = Array("Jan", "Feb", "Mar", "Apr", "May", _
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", _
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
vReplText = Array("January", "February", "March", _
"April", "May", "June", "July", "August", "September", _
"October", "November", "December", "Monday", "Tuesday", _
"Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = vReplText(i)
.Execute replace:=wdReplaceAll
Next i
End With
End Sub

Sub TransposeDates()
Dim vFindText As Variant
Dim i As Long
vFindText = Array("(January) ([0-9]{1,2}), ([0-9]{4})", _
"(February) ([0-9]{1,2}), ([0-9]{4})", _
"(March) ([0-9]{1,2}), ([0-9]{4})", _
"(April) ([0-9]{1,2}), ([0-9]{4})", _
"(May) ([0-9]{1,2}), ([0-9]{4})", _
"(June) ([0-9]{1,2}), ([0-9]{4})", _
"(July) ([0-9]{1,2}), ([0-9]{4})", _
"(August) ([0-9]{1,2}), ([0-9]{4})", _
"(September) ([0-9]{1,2}), ([0-9]{4})", _
"(October) ([0-9]{1,2}), ([0-9]{4})", _
"(November) ([0-9]{1,2}), ([0-9]{4})", _
"(December) ([0-9]{1,2}), ([0-9]{4})")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = "\2 \1 \3"
.Execute replace:=wdReplaceAll
Next i
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Johann said:
Hi Graham,
Thanks for your response.
I visited your site but did not find anything specifically that
addresses my particular situation. Or are you saying that one should
do a separate seach and replace for each month name and/or day name?
Regards
Johann

:

See http://www.gmayor.com/replace_using_wildcards.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Johann Swart wrote:
I apologise if this is not the correct category for placing these
questions; none of the others seem appropriate.

Is it possible in Word (2002 on Win2K) to search for the
abbreviation of any month (Jan to Dec) and replace it with the
full name, e.g. January, or December. LIkewise for the days of
the week, i.e. Sun to Sat, and replace it with Sunday, Saturday.

Also, is it possible by ways of a macro or otherwise to search
for; e.g "September 29, 2006" and replace it with "29 September
2006"?

If these are only possible by means of macros, would you be so
kind to provide the macro as I am VB illiterate.

Thank you
Johann
 
G

Graham Mayor

The following should do the trick :)

Sub TransposeDates()
Dim vFindText As Variant
Dim i As Long
vFindText = Array("(January) ([0-9]{1;2}), ([0-9]{4})", _
"(February) ([0-9]{1;2}), ([0-9]{4})", _
"(March) ([0-9]{1;2}), ([0-9]{4})", _
"(April) ([0-9]{1;2}), ([0-9]{4})", _
"(May) ([0-9]{1;2}), ([0-9]{4})", _
"(June) ([0-9]{1;2}), ([0-9]{4})", _
"(July) ([0-9]{1;2}), ([0-9]{4})", _
"(August) ([0-9]{1;2}), ([0-9]{4})", _
"(September) ([0-9]{1;2}), ([0-9]{4})", _
"(October) ([0-9]{1;2}), ([0-9]{4})", _
"(November) ([0-9]{1;2}), ([0-9]{4})", _
"(December) ([0-9]{1;2}), ([0-9]{4})")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = "\2 \1 \3"
.Execute replace:=wdReplaceAll
Next i
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Graham said:
Yes - it is the regional settings that are screwing it up :(
The problem is the comma separator between the 1&2
([0-9]{1,2})
in each date. Change that for whatever you use locally and it should
work.

Johann said:
Hi Graham,
Thank you very much.
I have installed both, and the first one (Replace List) works 100%.
However, the second one (Transpose Dates) *seems* to have glitch. The
debugger highlights the fourth last line (.Execute
Replace:=wdReplaceAll). Could it possibly be as a result of my
Windows Regional Settings which has a decimal comma, and a semicolon
as a list separator?

Graham Mayor said:
Unless they are date fields, you will have to search each short
version and replace with the longer version. The transposed dates
are a different issue and again you will have to search each
combination using a wildcard search - hence the link. The following
macros will do both tasks http://www.gmayor.com/installing_macro.htm

Sub ReplaceList()
Dim vFindText As Variant
Dim vReplText As Variant
Dim i As Long
vFindText = Array("Jan", "Feb", "Mar", "Apr", "May", _
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", _
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
vReplText = Array("January", "February", "March", _
"April", "May", "June", "July", "August", "September", _
"October", "November", "December", "Monday", "Tuesday", _
"Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = vReplText(i)
.Execute replace:=wdReplaceAll
Next i
End With
End Sub

Sub TransposeDates()
Dim vFindText As Variant
Dim i As Long
vFindText = Array("(January) ([0-9]{1,2}), ([0-9]{4})", _
"(February) ([0-9]{1,2}), ([0-9]{4})", _
"(March) ([0-9]{1,2}), ([0-9]{4})", _
"(April) ([0-9]{1,2}), ([0-9]{4})", _
"(May) ([0-9]{1,2}), ([0-9]{4})", _
"(June) ([0-9]{1,2}), ([0-9]{4})", _
"(July) ([0-9]{1,2}), ([0-9]{4})", _
"(August) ([0-9]{1,2}), ([0-9]{4})", _
"(September) ([0-9]{1,2}), ([0-9]{4})", _
"(October) ([0-9]{1,2}), ([0-9]{4})", _
"(November) ([0-9]{1,2}), ([0-9]{4})", _
"(December) ([0-9]{1,2}), ([0-9]{4})")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = "\2 \1 \3"
.Execute replace:=wdReplaceAll
Next i
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Johann Swart wrote:
Hi Graham,
Thanks for your response.
I visited your site but did not find anything specifically that
addresses my particular situation. Or are you saying that one
should do a separate seach and replace for each month name and/or
day name? Regards
Johann

:

See http://www.gmayor.com/replace_using_wildcards.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Johann Swart wrote:
I apologise if this is not the correct category for placing these
questions; none of the others seem appropriate.

Is it possible in Word (2002 on Win2K) to search for the
abbreviation of any month (Jan to Dec) and replace it with the
full name, e.g. January, or December. LIkewise for the days of
the week, i.e. Sun to Sat, and replace it with Sunday, Saturday.

Also, is it possible by ways of a macro or otherwise to search
for; e.g "September 29, 2006" and replace it with "29 September
2006"?

If these are only possible by means of macros, would you be so
kind to provide the macro as I am VB illiterate.

Thank you
Johann
 
J

Johann Swart

Excellent!
Many, many thanks for patience and assistance; this is going to save me
untold hours of toil.
Greetings
Johann

Graham Mayor said:
The following should do the trick :)

Sub TransposeDates()
Dim vFindText As Variant
Dim i As Long
vFindText = Array("(January) ([0-9]{1;2}), ([0-9]{4})", _
"(February) ([0-9]{1;2}), ([0-9]{4})", _
"(March) ([0-9]{1;2}), ([0-9]{4})", _
"(April) ([0-9]{1;2}), ([0-9]{4})", _
"(May) ([0-9]{1;2}), ([0-9]{4})", _
"(June) ([0-9]{1;2}), ([0-9]{4})", _
"(July) ([0-9]{1;2}), ([0-9]{4})", _
"(August) ([0-9]{1;2}), ([0-9]{4})", _
"(September) ([0-9]{1;2}), ([0-9]{4})", _
"(October) ([0-9]{1;2}), ([0-9]{4})", _
"(November) ([0-9]{1;2}), ([0-9]{4})", _
"(December) ([0-9]{1;2}), ([0-9]{4})")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = "\2 \1 \3"
.Execute replace:=wdReplaceAll
Next i
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Graham said:
Yes - it is the regional settings that are screwing it up :(
The problem is the comma separator between the 1&2
([0-9]{1,2})
in each date. Change that for whatever you use locally and it should
work.

Johann said:
Hi Graham,
Thank you very much.
I have installed both, and the first one (Replace List) works 100%.
However, the second one (Transpose Dates) *seems* to have glitch. The
debugger highlights the fourth last line (.Execute
Replace:=wdReplaceAll). Could it possibly be as a result of my
Windows Regional Settings which has a decimal comma, and a semicolon
as a list separator?

:

Unless they are date fields, you will have to search each short
version and replace with the longer version. The transposed dates
are a different issue and again you will have to search each
combination using a wildcard search - hence the link. The following
macros will do both tasks http://www.gmayor.com/installing_macro.htm

Sub ReplaceList()
Dim vFindText As Variant
Dim vReplText As Variant
Dim i As Long
vFindText = Array("Jan", "Feb", "Mar", "Apr", "May", _
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", _
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
vReplText = Array("January", "February", "March", _
"April", "May", "June", "July", "August", "September", _
"October", "November", "December", "Monday", "Tuesday", _
"Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = vReplText(i)
.Execute replace:=wdReplaceAll
Next i
End With
End Sub

Sub TransposeDates()
Dim vFindText As Variant
Dim i As Long
vFindText = Array("(January) ([0-9]{1,2}), ([0-9]{4})", _
"(February) ([0-9]{1,2}), ([0-9]{4})", _
"(March) ([0-9]{1,2}), ([0-9]{4})", _
"(April) ([0-9]{1,2}), ([0-9]{4})", _
"(May) ([0-9]{1,2}), ([0-9]{4})", _
"(June) ([0-9]{1,2}), ([0-9]{4})", _
"(July) ([0-9]{1,2}), ([0-9]{4})", _
"(August) ([0-9]{1,2}), ([0-9]{4})", _
"(September) ([0-9]{1,2}), ([0-9]{4})", _
"(October) ([0-9]{1,2}), ([0-9]{4})", _
"(November) ([0-9]{1,2}), ([0-9]{4})", _
"(December) ([0-9]{1,2}), ([0-9]{4})")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = "\2 \1 \3"
.Execute replace:=wdReplaceAll
Next i
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Johann Swart wrote:
Hi Graham,
Thanks for your response.
I visited your site but did not find anything specifically that
addresses my particular situation. Or are you saying that one
should do a separate seach and replace for each month name and/or
day name? Regards
Johann

:

See http://www.gmayor.com/replace_using_wildcards.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Johann Swart wrote:
I apologise if this is not the correct category for placing these
questions; none of the others seem appropriate.

Is it possible in Word (2002 on Win2K) to search for the
abbreviation of any month (Jan to Dec) and replace it with the
full name, e.g. January, or December. LIkewise for the days of
the week, i.e. Sun to Sat, and replace it with Sunday, Saturday.

Also, is it possible by ways of a macro or otherwise to search
for; e.g "September 29, 2006" and replace it with "29 September
2006"?

If these are only possible by means of macros, would you be so
kind to provide the macro as I am VB illiterate.

Thank you
Johann
 
G

Graham Mayor

You are welcome

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Johann said:
Excellent!
Many, many thanks for patience and assistance; this is going to save
me untold hours of toil.
Greetings
Johann

Graham Mayor said:
The following should do the trick :)

Sub TransposeDates()
Dim vFindText As Variant
Dim i As Long
vFindText = Array("(January) ([0-9]{1;2}), ([0-9]{4})", _
"(February) ([0-9]{1;2}), ([0-9]{4})", _
"(March) ([0-9]{1;2}), ([0-9]{4})", _
"(April) ([0-9]{1;2}), ([0-9]{4})", _
"(May) ([0-9]{1;2}), ([0-9]{4})", _
"(June) ([0-9]{1;2}), ([0-9]{4})", _
"(July) ([0-9]{1;2}), ([0-9]{4})", _
"(August) ([0-9]{1;2}), ([0-9]{4})", _
"(September) ([0-9]{1;2}), ([0-9]{4})", _
"(October) ([0-9]{1;2}), ([0-9]{4})", _
"(November) ([0-9]{1;2}), ([0-9]{4})", _
"(December) ([0-9]{1;2}), ([0-9]{4})")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = "\2 \1 \3"
.Execute replace:=wdReplaceAll
Next i
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Graham said:
Yes - it is the regional settings that are screwing it up :(
The problem is the comma separator between the 1&2
([0-9]{1,2})
in each date. Change that for whatever you use locally and it should
work.

Johann Swart wrote:
Hi Graham,
Thank you very much.
I have installed both, and the first one (Replace List) works 100%.
However, the second one (Transpose Dates) *seems* to have glitch.
The debugger highlights the fourth last line (.Execute
Replace:=wdReplaceAll). Could it possibly be as a result of my
Windows Regional Settings which has a decimal comma, and a
semicolon as a list separator?

:

Unless they are date fields, you will have to search each short
version and replace with the longer version. The transposed dates
are a different issue and again you will have to search each
combination using a wildcard search - hence the link. The
following macros will do both tasks
http://www.gmayor.com/installing_macro.htm

Sub ReplaceList()
Dim vFindText As Variant
Dim vReplText As Variant
Dim i As Long
vFindText = Array("Jan", "Feb", "Mar", "Apr", "May", _
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", _
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
vReplText = Array("January", "February", "March", _
"April", "May", "June", "July", "August", "September", _
"October", "November", "December", "Monday", "Tuesday", _
"Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = vReplText(i)
.Execute replace:=wdReplaceAll
Next i
End With
End Sub

Sub TransposeDates()
Dim vFindText As Variant
Dim i As Long
vFindText = Array("(January) ([0-9]{1,2}), ([0-9]{4})", _
"(February) ([0-9]{1,2}), ([0-9]{4})", _
"(March) ([0-9]{1,2}), ([0-9]{4})", _
"(April) ([0-9]{1,2}), ([0-9]{4})", _
"(May) ([0-9]{1,2}), ([0-9]{4})", _
"(June) ([0-9]{1,2}), ([0-9]{4})", _
"(July) ([0-9]{1,2}), ([0-9]{4})", _
"(August) ([0-9]{1,2}), ([0-9]{4})", _
"(September) ([0-9]{1,2}), ([0-9]{4})", _
"(October) ([0-9]{1,2}), ([0-9]{4})", _
"(November) ([0-9]{1,2}), ([0-9]{4})", _
"(December) ([0-9]{1,2}), ([0-9]{4})")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = True
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True
For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = "\2 \1 \3"
.Execute replace:=wdReplaceAll
Next i
End With
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Johann Swart wrote:
Hi Graham,
Thanks for your response.
I visited your site but did not find anything specifically that
addresses my particular situation. Or are you saying that one
should do a separate seach and replace for each month name and/or
day name? Regards
Johann

:

See http://www.gmayor.com/replace_using_wildcards.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Johann Swart wrote:
I apologise if this is not the correct category for placing
these questions; none of the others seem appropriate.

Is it possible in Word (2002 on Win2K) to search for the
abbreviation of any month (Jan to Dec) and replace it with the
full name, e.g. January, or December. LIkewise for the days of
the week, i.e. Sun to Sat, and replace it with Sunday,
Saturday.

Also, is it possible by ways of a macro or otherwise to search
for; e.g "September 29, 2006" and replace it with "29 September
2006"?

If these are only possible by means of macros, would you be so
kind to provide the macro as I am VB illiterate.

Thank you
Johann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top