Hello to those of superior intelect!
I am working with a program which creates word documents with dates in the format 4th June 2011 (the suffix is not superscripted) and I need to be able to change the date format to 4 June 2011.
My question is this; 'How do I remove the ordinal suffix?'
I have the following code (it continues until 31) which does work but I was wondering if anyone knows of a tidier and/or more efficient way of solving it (I'm sure there is!):
Obviously bear in mind that there are words such as 'then' 'stick' and 'sand' where I do not want the th, st and nd removed.Code:Sub Ordinals() Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting Selection.Find.Replacement.Font.Underline = wdUnderlineNone With Selection.Find .Text = "1st" .Text = "2nd" .Replacement.Text = "2" .Forward = True .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False Selection.Find.Execute Replace:=wdReplaceAll Selection.HomeKey Unit:=wdStory .Text = "Engaged" .Replacement.Text = "Engaged -" .Forward = True .Format = False .MatchCase = False .MatchWholeWord = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False Selection.Find.Execute Replace:=wdReplaceAll Selection.HomeKey Unit:=wdStory .Text = "% *" .Replacement.Text = "%" .Forward = True .Format = False .MatchCase = False .MatchWholeWord = True .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False Selection.Find.Execute Replace:=wdReplaceAll End With Selection.WholeStory Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify Selection.HomeKey Unit:=wdStory End Sub




Reply With Quote
