Create Field Macro

S

snyderdm2005

I want to create a field macro that changes my text 09/14/96 to September 14,
1996 without calculating from today's date. Say text change ##/##/##=MMMM d,
yyyy. Any ideas who to do this?
 
G

Greg Maxey

I don't see where fields have a role in your objective. Your want to find
text dates in the format of 09/14/96 and convert them to text dates in the
format September 14, 1996 correct?

Try this:

Sub ScratchMaco()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "[0-9]{2}/[0-9]{2}/[0-9]{2,}"
.MatchWildcards = True
While .Execute
If IsDate(oRng.Text) Then
oRng = Format(oRng, "MMMM d, yyyy")
oRng.Collapse wdCollapseEnd
End If
Wend
End With
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