Date Picker format to include a suffix after the day ie. 1st January 2011


using microsoft word 2010 have inserted date picker content control wish change format include suffix after day ie. 1st january 2011 etc.  any ideas on format should using.  i thought ds mmmm yyyy.  this inserts number though.  any ideas be greatly appreciated - thank you!

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

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Can no longer user MS Update - Files required to use Microsoft Update are no longer registered

How do a find data in one file, search for it in another file and if not found, write a custom message to another file