Convert MMDDYY to Text--Need with with my Macro

K

Kim

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

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
Selection.Find.Execute FindText:="2020", Replacewith:="20",
Replace:=wdReplaceAll
Selection.Find.Execute FindText:="2019", Replacewith:="19",
Replace:=wdReplaceAll

Application.ScreenUpdating = True
Selection.ClearFormatting


End Sub
 
D

Doug Robbins - Word MVP

See answer to later post.

--
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 said:
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

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
Selection.Find.Execute FindText:="2020", Replacewith:="20",
Replace:=wdReplaceAll
Selection.Find.Execute FindText:="2019", Replacewith:="19",
Replace:=wdReplaceAll

Application.ScreenUpdating = True
Selection.ClearFormatting


End Sub
 

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