Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2007

Tip: Looking for answers? Try searching our database.

Convert MMDDYY to Text--Need with with my Macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kim - 06 Feb 2007 16:51 GMT
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
Doug Robbins - Word MVP - 06 Feb 2007 19:41 GMT
See answer to later post.

Signature

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

> Below is is my macro to find the date in the current selection only
> and convert it to text. I am having two problems.
[quoted text clipped - 97 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.