![]() |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
You make things harder than they have to be:
Code:
Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 7/7/2017 Dim oRng As Range Set oRng = ActiveDocument.Range With oRng.Find .ClearFormatting .Replacement.ClearFormatting .Text = "([0-9]{1,2})[/]([0-9]{1,2})[/]([0-9]{4})" .Format = True .Forward = True .MatchWildcards = True While .Execute With oRng If IsDate(.Text) Then .Text = Format(oRng.Text, "dd.mm.yyyy") .Font.Underline = True End If .Collapse wdCollapseEnd End With Wend End With lbl_Exit: Exit Sub End Sub |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Wriggly red underline
|
kirkm | Word | 3 | 09-18-2016 07:50 PM |
Hyperlinks: Removing Underline
|
reRanger | Word | 2 | 08-04-2016 02:29 AM |
Underline a tab
|
Futsal1st | Word | 2 | 10-25-2015 05:31 PM |
Underline at bottom of page won't go away
|
yachts66 | Word | 3 | 08-13-2014 07:28 AM |
Hyperlink - delete underline
|
Savana | PowerPoint | 5 | 04-13-2011 12:34 AM |