J
jerem
When I use the following macro, what reference range is being employed that
makes certain decisions for the conversion? For example, when I have a date
of 1/12/46, this converts to January 12, 1946, not January 12, 2046; when I
have a date of 1/14/20, this converts to January 14, 2020, not January 14,
1920; when I have a date of 2/3//10 this converts to February 3, 2010 not
February 3, 1910??? Seems like this was only project so far into the future.
I haven't tried all numbers but once you reach that boundary it assigns the
20th century to any number there and above.
Sub NumberDatesToWordDates()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "[0-9]{1,}/[0-9]{1,}/[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
makes certain decisions for the conversion? For example, when I have a date
of 1/12/46, this converts to January 12, 1946, not January 12, 2046; when I
have a date of 1/14/20, this converts to January 14, 2020, not January 14,
1920; when I have a date of 2/3//10 this converts to February 3, 2010 not
February 3, 1910??? Seems like this was only project so far into the future.
I haven't tried all numbers but once you reach that boundary it assigns the
20th century to any number there and above.
Sub NumberDatesToWordDates()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "[0-9]{1,}/[0-9]{1,}/[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