Thread: underline date
View Single Post
 
Old 07-07-2017, 10:20 AM
rakesh seebaruth rakesh seebaruth is offline Windows 10 Office 2010 64bit
Novice
 
Join Date: Jul 2017
Posts: 2
rakesh seebaruth is on a distinguished road
Default underline date

hi guys

i have the following vba codes which converts dates to dd.mm.yyyy

Sub GetDateAndReplace()
Dim FoundOne As Boolean

Selection.HomeKey Unit:=wdStory, Extend:=wdMove
FoundOne = True ' loop at least once

Do While FoundOne ' loop until no date is found
With Selection.Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "([0-9]{1,2})[/]([0-9]{1,2})[/]([0-9]{4})"
.Format = True
.Forward = True
.MatchWildcards = True
End With

Selection.Find.Execute Replace:=wdReplaceNone

' check the find to be sure it's a date
If IsDate(Selection.Text) Then
Selection.Text = Format(Selection.Text, "dd.mm.yyyy")
Selection.Collapse wdCollapseEnd
Else ' not a date - end loop
FoundOne = False
End If
Loop

End Sub

i want vba to underline the dates which have been converted to dd.mm.yyyy

thanks/regards

rakesh
Reply With Quote