Below is is my macro to find the date in the current selection only
and convert it to text. I am having two problems.

1. I don't want to be asked if I want to find and replace thoughout
the document, so I need to have Screen updating off. The first time I
run this macro in a document I do not have a problem. The second time
I run the macro it asks me if I want to search and replace throughout
the rest of the document. Which is not what I need.


2. Now this macro is changing my 01/01/06 dates to October 1, 2006
and
I can't see why.


Please help!!


Sub Convert_MMDDYY_to_Text()


Application.ScreenUpdating = False
Selection.ClearFormatting


Selection.Find.Execute FindText:="<[01]{1,2}/([0-9]{1,2})/([0-9]
{2,4})", MatchWildcards:=True, Replacewith:="January \1, 20\2",
Replace:=wdReplaceAll
Selection.Find.Execute FindText:="<[12]{2}/([0-9]{1,2})/([0-9]
{2,4})", MatchWildcards:=True, Replacewith:="December \1, 20\2",
Replace:=wdReplaceAll
Selection.Find.Execute FindText:="<[11]{2}/([0-9]{1,2})/([0-9]
{2,4})", MatchWildcards:=True, Replacewith:="November \1, 20\2",
Replace:=wdReplaceAll
Selection.Find.Execute FindText:="<[10]{2}/([0-9]{1,2})/([0-9]
{2,4})", MatchWildcards:=True, Replacewith:="October \1, 20\2",
Replace:=wdReplaceAll
Selection.Find.Execute FindText:="<[09]{1,2}/([0-9]{1,2})/([0-9]
{2,4})", MatchWildcards:=True, Replacewith:="September \1, 20\2",
Replace:=wdReplaceAll
Selection.Find.Execute FindText:="<[08]{1,2}/([0-9]{1,2})/([0-9]
{2,4})", MatchWildcards:=True, Replacewith:="August \1, 20\2",
Replace:=wdReplaceAll
Selection.Find.Execute FindText:="<[07]{1,2}/([0-9]{1,2})/([0-9]
{2,4})", MatchWildcards:=True, Replacewith:="July \1, 20\2",
Replace:=wdReplaceAll
Selection.Find.Execute FindText:="<[06]{1,2}/([0-9]{1,2})/([0-9]
{2,4})", MatchWildcards:=True, Replacewith:="June \1, 20\2",
Replace:=wdReplaceAll
Selection.Find.Execute FindText:="<[05]{1,2}/([0-9]{1,2})/([0-9]
{2,4})", MatchWildcards:=True, Replacewith:="May \1, 20\2",
Replace:=wdReplaceAll
Selection.Find.Execute FindText:="<[04]{1,2}/([0-9]{1,2})/([0-9]
{2,4})", MatchWildcards:=True, Replacewith:="April \1, 20\2",
Replace:=wdReplaceAll
Selection.Find.Execute FindText:="<[03]{1,2}/([0-9]{1,2})/([0-9]
{2,4})", MatchWildcards:=True, Replacewith:="March \1, 20\2",
Replace:=wdReplaceAll
Selection.Find.Execute FindText:="<[02]{1,2}/([0-9]{1,2})/([0-9]
{2,4})", MatchWildcards:=True, Replacewith:="February \1, 20\2",
Replace:=wdReplaceAll

Re: Need Macro help to Convert date to text by Kim

Kim
Tue Feb 06 11:24:37 CST 2007

On Feb 6, 11:19 am, "Kim" <kholm...@comcast.net> wrote:
> Below is is my macro to find the date in the current selection only
> and convert it to text. I am having two problems.
>
> 1. I don't want to be asked if I want to find and replace thoughout
> the document, so I need to have Screen updating off. The first time I
> run this macro in a document I do not have a problem. The second time
> I run the macro it asks me if I want to search and replace throughout
> the rest of the document. Which is not what I need.
>
> 2. Now this macro is changing my 01/01/06 dates to October 1, 2006
> and
> I can't see why.
>
> Please help!!
>
> Sub Convert_MMDDYY_to_Text()
>
> Application.ScreenUpdating = False
> Selection.ClearFormatting
>
> Selection.Find.Execute FindText:="<[01]{1,2}/([0-9]{1,2})/([0-9]
> {2,4})", MatchWildcards:=True, Replacewith:="January \1, 20\2",
> Replace:=wdReplaceAll
> Selection.Find.Execute FindText:="<[12]{2}/([0-9]{1,2})/([0-9]
> {2,4})", MatchWildcards:=True, Replacewith:="December \1, 20\2",
> Replace:=wdReplaceAll
> Selection.Find.Execute FindText:="<[11]{2}/([0-9]{1,2})/([0-9]
> {2,4})", MatchWildcards:=True, Replacewith:="November \1, 20\2",
> Replace:=wdReplaceAll
> Selection.Find.Execute FindText:="<[10]{2}/([0-9]{1,2})/([0-9]
> {2,4})", MatchWildcards:=True, Replacewith:="October \1, 20\2",
> Replace:=wdReplaceAll
> Selection.Find.Execute FindText:="<[09]{1,2}/([0-9]{1,2})/([0-9]
> {2,4})", MatchWildcards:=True, Replacewith:="September \1, 20\2",
> Replace:=wdReplaceAll
> Selection.Find.Execute FindText:="<[08]{1,2}/([0-9]{1,2})/([0-9]
> {2,4})", MatchWildcards:=True, Replacewith:="August \1, 20\2",
> Replace:=wdReplaceAll
> Selection.Find.Execute FindText:="<[07]{1,2}/([0-9]{1,2})/([0-9]
> {2,4})", MatchWildcards:=True, Replacewith:="July \1, 20\2",
> Replace:=wdReplaceAll
> Selection.Find.Execute FindText:="<[06]{1,2}/([0-9]{1,2})/([0-9]
> {2,4})", MatchWildcards:=True, Replacewith:="June \1, 20\2",
> Replace:=wdReplaceAll
> Selection.Find.Execute FindText:="<[05]{1,2}/([0-9]{1,2})/([0-9]
> {2,4})", MatchWildcards:=True, Replacewith:="May \1, 20\2",
> Replace:=wdReplaceAll
> Selection.Find.Execute FindText:="<[04]{1,2}/([0-9]{1,2})/([0-9]
> {2,4})", MatchWildcards:=True, Replacewith:="April \1, 20\2",
> Replace:=wdReplaceAll
> Selection.Find.Execute FindText:="<[03]{1,2}/([0-9]{1,2})/([0-9]
> {2,4})", MatchWildcards:=True, Replacewith:="March \1, 20\2",
> Replace:=wdReplaceAll
> Selection.Find.Execute FindText:="<[02]{1,2}/([0-9]{1,2})/([0-9]
> {2,4})", MatchWildcards:=True, Replacewith:="February \1, 20\2",
> Replace:=wdReplaceAll

One more thing, the replace is changing everywhere in the document, I
just want my highlighted selection!


Re: Need Macro help to Convert date to text by Doug

Doug
Tue Feb 06 13:40:41 CST 2007

Use:

Dim trange As Range
Dim frange As Range
Set frange = Selection.Range
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{2,4}",
MatchWildcards:=True, Wrap:=wdFindStop, Forward:=True) = True
Set trange = Selection.Range
If trange.Start < frange.End Then
trange.Text = Format(trange.Text, "MMMM dd, yyyy")
Else
Exit Sub
End If
Loop
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"Kim" <kholmen1@comcast.net> wrote in message
news:1170782677.749746.65040@a75g2000cwd.googlegroups.com...
> On Feb 6, 11:19 am, "Kim" <kholm...@comcast.net> wrote:
>> Below is is my macro to find the date in the current selection only
>> and convert it to text. I am having two problems.
>>
>> 1. I don't want to be asked if I want to find and replace thoughout
>> the document, so I need to have Screen updating off. The first time I
>> run this macro in a document I do not have a problem. The second time
>> I run the macro it asks me if I want to search and replace throughout
>> the rest of the document. Which is not what I need.
>>
>> 2. Now this macro is changing my 01/01/06 dates to October 1, 2006
>> and
>> I can't see why.
>>
>> Please help!!
>>
>> Sub Convert_MMDDYY_to_Text()
>>
>> Application.ScreenUpdating = False
>> Selection.ClearFormatting
>>
>> Selection.Find.Execute FindText:="<[01]{1,2}/([0-9]{1,2})/([0-9]
>> {2,4})", MatchWildcards:=True, Replacewith:="January \1, 20\2",
>> Replace:=wdReplaceAll
>> Selection.Find.Execute FindText:="<[12]{2}/([0-9]{1,2})/([0-9]
>> {2,4})", MatchWildcards:=True, Replacewith:="December \1, 20\2",
>> Replace:=wdReplaceAll
>> Selection.Find.Execute FindText:="<[11]{2}/([0-9]{1,2})/([0-9]
>> {2,4})", MatchWildcards:=True, Replacewith:="November \1, 20\2",
>> Replace:=wdReplaceAll
>> Selection.Find.Execute FindText:="<[10]{2}/([0-9]{1,2})/([0-9]
>> {2,4})", MatchWildcards:=True, Replacewith:="October \1, 20\2",
>> Replace:=wdReplaceAll
>> Selection.Find.Execute FindText:="<[09]{1,2}/([0-9]{1,2})/([0-9]
>> {2,4})", MatchWildcards:=True, Replacewith:="September \1, 20\2",
>> Replace:=wdReplaceAll
>> Selection.Find.Execute FindText:="<[08]{1,2}/([0-9]{1,2})/([0-9]
>> {2,4})", MatchWildcards:=True, Replacewith:="August \1, 20\2",
>> Replace:=wdReplaceAll
>> Selection.Find.Execute FindText:="<[07]{1,2}/([0-9]{1,2})/([0-9]
>> {2,4})", MatchWildcards:=True, Replacewith:="July \1, 20\2",
>> Replace:=wdReplaceAll
>> Selection.Find.Execute FindText:="<[06]{1,2}/([0-9]{1,2})/([0-9]
>> {2,4})", MatchWildcards:=True, Replacewith:="June \1, 20\2",
>> Replace:=wdReplaceAll
>> Selection.Find.Execute FindText:="<[05]{1,2}/([0-9]{1,2})/([0-9]
>> {2,4})", MatchWildcards:=True, Replacewith:="May \1, 20\2",
>> Replace:=wdReplaceAll
>> Selection.Find.Execute FindText:="<[04]{1,2}/([0-9]{1,2})/([0-9]
>> {2,4})", MatchWildcards:=True, Replacewith:="April \1, 20\2",
>> Replace:=wdReplaceAll
>> Selection.Find.Execute FindText:="<[03]{1,2}/([0-9]{1,2})/([0-9]
>> {2,4})", MatchWildcards:=True, Replacewith:="March \1, 20\2",
>> Replace:=wdReplaceAll
>> Selection.Find.Execute FindText:="<[02]{1,2}/([0-9]{1,2})/([0-9]
>> {2,4})", MatchWildcards:=True, Replacewith:="February \1, 20\2",
>> Replace:=wdReplaceAll
>
> One more thing, the replace is changing everywhere in the document, I
> just want my highlighted selection!
>



Re: Need Macro help to Convert date to text by Kim

Kim
Tue Feb 06 14:45:31 CST 2007

On Feb 6, 1:40 pm, "Doug Robbins - Word MVP" <d...@REMOVECAPSmvps.org>
wrote:
> Use:
>
> Dim trange As Range
> Dim frange As Range
> Set frange = Selection.Range
> Selection.Find.ClearFormatting
> With Selection.Find
> Do While .Execute(FindText:="[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{2,4}",
> MatchWildcards:=True, Wrap:=wdFindStop, Forward:=True) = True
> Set trange = Selection.Range
> If trange.Start < frange.End Then
> trange.Text = Format(trange.Text, "MMMM dd, yyyy")
> Else
> Exit Sub
> End If
> Loop
> End With
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "Kim" <kholm...@comcast.net> wrote in message
>
> news:1170782677.749746.65040@a75g2000cwd.googlegroups.com...
>
>
>
> > On Feb 6, 11:19 am, "Kim" <kholm...@comcast.net> wrote:
> >> Below is is my macro to find the date in the current selection only
> >> and convert it to text. I am having two problems.
>
> >> 1. I don't want to be asked if I want to find and replace thoughout
> >> the document, so I need to have Screen updating off. The first time I
> >> run this macro in a document I do not have a problem. The second time
> >> I run the macro it asks me if I want to search and replace throughout
> >> the rest of the document. Which is not what I need.
>
> >> 2. Now this macro is changing my 01/01/06 dates to October 1, 2006
> >> and
> >> I can't see why.
>
> >> Please help!!
>
> >> Sub Convert_MMDDYY_to_Text()
>
> >> Application.ScreenUpdating = False
> >> Selection.ClearFormatting
>
> >> Selection.Find.Execute FindText:="<[01]{1,2}/([0-9]{1,2})/([0-9]
> >> {2,4})", MatchWildcards:=True, Replacewith:="January \1, 20\2",
> >> Replace:=wdReplaceAll
> >> Selection.Find.Execute FindText:="<[12]{2}/([0-9]{1,2})/([0-9]
> >> {2,4})", MatchWildcards:=True, Replacewith:="December \1, 20\2",
> >> Replace:=wdReplaceAll
> >> Selection.Find.Execute FindText:="<[11]{2}/([0-9]{1,2})/([0-9]
> >> {2,4})", MatchWildcards:=True, Replacewith:="November \1, 20\2",
> >> Replace:=wdReplaceAll
> >> Selection.Find.Execute FindText:="<[10]{2}/([0-9]{1,2})/([0-9]
> >> {2,4})", MatchWildcards:=True, Replacewith:="October \1, 20\2",
> >> Replace:=wdReplaceAll
> >> Selection.Find.Execute FindText:="<[09]{1,2}/([0-9]{1,2})/([0-9]
> >> {2,4})", MatchWildcards:=True, Replacewith:="September \1, 20\2",
> >> Replace:=wdReplaceAll
> >> Selection.Find.Execute FindText:="<[08]{1,2}/([0-9]{1,2})/([0-9]
> >> {2,4})", MatchWildcards:=True, Replacewith:="August \1, 20\2",
> >> Replace:=wdReplaceAll
> >> Selection.Find.Execute FindText:="<[07]{1,2}/([0-9]{1,2})/([0-9]
> >> {2,4})", MatchWildcards:=True, Replacewith:="July \1, 20\2",
> >> Replace:=wdReplaceAll
> >> Selection.Find.Execute FindText:="<[06]{1,2}/([0-9]{1,2})/([0-9]
> >> {2,4})", MatchWildcards:=True, Replacewith:="June \1, 20\2",
> >> Replace:=wdReplaceAll
> >> Selection.Find.Execute FindText:="<[05]{1,2}/([0-9]{1,2})/([0-9]
> >> {2,4})", MatchWildcards:=True, Replacewith:="May \1, 20\2",
> >> Replace:=wdReplaceAll
> >> Selection.Find.Execute FindText:="<[04]{1,2}/([0-9]{1,2})/([0-9]
> >> {2,4})", MatchWildcards:=True, Replacewith:="April \1, 20\2",
> >> Replace:=wdReplaceAll
> >> Selection.Find.Execute FindText:="<[03]{1,2}/([0-9]{1,2})/([0-9]
> >> {2,4})", MatchWildcards:=True, Replacewith:="March \1, 20\2",
> >> Replace:=wdReplaceAll
> >> Selection.Find.Execute FindText:="<[02]{1,2}/([0-9]{1,2})/([0-9]
> >> {2,4})", MatchWildcards:=True, Replacewith:="February \1, 20\2",
> >> Replace:=wdReplaceAll
>
> > One more thing, the replace is changing everywhere in the document, I
> > just want my highlighted selection!- Hide quoted text -
>
> - Show quoted text -

Doug,

That worked, and REALLY well! I see I have a long way to go before
starting getting the correct way write VBA macros! I really appreciate
you help! BIG THANKS!