K
Kim
This macro will just change the text in the selected text, but it will
jump to the next date found in the document, which I don't want it to
do. Also, other times it will change the date in the selected text AND
change dates everywhere in the document. I have very large documents
and when it changes all dates in it that really takes me a long time
to undo all things I didn't want to change. Please help!
Sub Convert_MMDDYY_to_Text()
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 d, yyyy")
Else
Exit Sub
End If
Loop
End With
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 d, yyyy")
Else
Exit Sub
End If
Loop
End With
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[0-9]{1,2}\-[0-9]{1,2}\-[0-9]{4}",
MatchWildcards:=True, Wrap:=wdFindStop, Forward:=True) = True
Set trange = Selection.Range
If trange.Start < frange.End Then
trange.Text = Format(trange.Text, "MMMM d, yyyy")
Else
Exit Sub
End If
Loop
End With
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}",
MatchWildcards:=True, Wrap:=wdFindStop, Forward:=True) = True
Set trange = Selection.Range
If trange.Start < frange.End Then
trange.Text = Format(trange.Text, "MMMM d, yyyy")
Else
Exit Sub
End If
Loop
End With
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
End Sub
jump to the next date found in the document, which I don't want it to
do. Also, other times it will change the date in the selected text AND
change dates everywhere in the document. I have very large documents
and when it changes all dates in it that really takes me a long time
to undo all things I didn't want to change. Please help!
Sub Convert_MMDDYY_to_Text()
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 d, yyyy")
Else
Exit Sub
End If
Loop
End With
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 d, yyyy")
Else
Exit Sub
End If
Loop
End With
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[0-9]{1,2}\-[0-9]{1,2}\-[0-9]{4}",
MatchWildcards:=True, Wrap:=wdFindStop, Forward:=True) = True
Set trange = Selection.Range
If trange.Start < frange.End Then
trange.Text = Format(trange.Text, "MMMM d, yyyy")
Else
Exit Sub
End If
Loop
End With
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}",
MatchWildcards:=True, Wrap:=wdFindStop, Forward:=True) = True
Set trange = Selection.Range
If trange.Start < frange.End Then
trange.Text = Format(trange.Text, "MMMM d, yyyy")
Else
Exit Sub
End If
Loop
End With
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
End Sub