Date Picker format to include a suffix after the day ie. 1st January 2011
here's macro both adds ordinal suffix , superscripts it:
private sub document_contentcontrolonexit(byval contentcontrol contentcontrol, cancel boolean)
dim long, j string, rng range
contentcontrol
if .type <> wdcontentcontroldate exit sub
.type = wdcontentcontrolrichtext
set rng = .range
if .title = "mydate" then
= 0 ubound(split(.range.text, " "))
j = split(.range.text, " ")(i)
if isnumeric(j) then
rng
.start = .start + instr(contentcontrol.range.text, j) + len(j) - 1
.end = .start
.insertafter ordinal(val(j))
.font.superscript = true
end with
.type = wdcontentcontroldate
exit for
end if
next
end if
end with
end sub
function ordinal(val integer) string
dim strord string
if (val mod 100) < 11 or (val mod 100) > 13 strord = choose(val mod 10, "st", "nd", "rd") & ""
ordinal = iif(strord = "", "th", strord)
end function
with above, it's assumed content control titled 'mydate'. you add code document's 'this document' module.
cheers
paul edstein
[ms mvp - word]
Microsoft Office > Word IT Pro Discussions
Comments
Post a Comment