+ Reply to Thread
Results 1 to 4 of 4

Superscript ordinal numbers in CreateDate field

  1. #1
    Registered User
    Join Date
    04-14-2014
    Location
    London, UK
    MS-Off Ver
    Office 2003
    Posts
    2

    Question Superscript ordinal numbers in CreateDate field

    I am trying to get the ordinal number suffixes in a CreateDate field to automatically be formatted as superscript in new documents created from a Word template (i.e. the "th" in "14th" should be superscript).

    I've found the following macro on Graham Mayor's excellent site (http://www.gmayor.com/formatting_word_fields.htm) and it works as it's supposed to, but it removes all formatting from the text and I want to maintain the font, colour and allignment settings.
    Sub AutoNew()
    ' FormatDate Macro
    Selection.GoTo What:=wdGoToBookmark, Name:="Date"
    Selection.Find.ClearFormatting
    With Options
    AutoFormatReplaceOrdinals = True
    End With
    Selection.Range.AutoFormat
    Selection.EscapeKey
    Selection.Fields.Unlink
    Selection.EndKey Unit:=wdLine
    End Sub
    I've played around trying to modify it but just don't have the required knowledge. I have also tried achieving a similar outcome using field codes but have been even less successful.

    Any help would be much appreciated.

    Thanks,
    Alexis

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Superscript ordinal numbers in CreateDate field

    Unfortunately, applying 'AutoFormat' does that. You could use:
    Please Login or Register  to view this content.
    FWIW, instead of relying on a macro, you could simply(?) encode the field as:
    {QUOTE{CREATEDATE \@ "dddd 'the' d"}{IF{=(MOD({={CREATEDATE \@ d}+89},100)>2)*(MOD({={CREATEDATE \@ d}+9},10)<3)}= 1 {=MOD({CREATEDATE \@ d},10)-2 \# rd;st;nd} th}{CREATEDATE \@ "' of' MMMM, yyyy"}}
    with the rd, st, nd & th all superscripted.

    Note: The field brace pairs (ie '{ }') for the above example are created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practicable to add them via any of the standard Word dialogues. There's a working field code that does this with DATE field in my Microsoft Word Date Calculation Tutorial, at:
    http://windowssecrets.com/forums/sho...ation-Tutorial
    or:
    http://www.gmayor.com/downloads.htm#Third_party
    In particular, look at the item titled 'Insert A Date with Ordinal Numbering'. All you need do is change the 'DATE' expressions in the field code there to 'CREATEDATE'. Do read the document's introductory material.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    04-14-2014
    Location
    London, UK
    MS-Off Ver
    Office 2003
    Posts
    2

    Re: Superscript ordinal numbers in CreateDate field

    Very helpful - thank you. I tried both options and, after some head scratching, I got the field codes working - definitely the better solution.

    When I tried using field codes before I hadn't got my head around the fact that you could create a new field within a field so I didn't understand what people meant when they said you couldn't type or paste the field braces. For future reference, is there an easier way of creating fields than via Insert>Field and then choosing a field name, Ctrl-F9, deleting the text between the braces and then repeating the process for the 'subsidiary' fields? I'm sure the answer must be yes!

    Cheers,
    Alexis

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Superscript ordinal numbers in CreateDate field

    Quote Originally Posted by alexisn View Post
    For future reference, is there an easier way of creating fields than via Insert>Field and then choosing a field name, Ctrl-F9, deleting the text between the braces and then repeating the process for the 'subsidiary' fields? I'm sure the answer must be yes!
    After pasting the textual representation of the field into the document, you could insert the true field braces and, once all of that is done, delete the text ones via Find/Replace.

    You could also have just downloaded the tutorial, copy/paste the field code from there, then use Find/Replace to change DATE to CREATEDATE.

    Another option is to paste the textual representation of the field into the document, then use a macro like the one at http://www.gmayor.com/export_field.htm#TextToField to turn it into a working field.

    or you could create all the fields - { { }{ { { { } }{ { } } }{ { } } }{ } } - then paste the remaining text into them...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. serial (ordinal) numbers after filtering
    By zookey in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 06-12-2016, 12:35 PM
  2. Ordinal Dates and numbers (st,nd,rd,th)
    By squiggler47 in forum Tips and Tutorials
    Replies: 5
    Last Post: 05-24-2014, 02:23 PM
  3. Ordinal dates and numbers in Excel 2007 or later
    By Tony Valko in forum Tips and Tutorials
    Replies: 2
    Last Post: 05-27-2013, 09:14 PM
  4. Ordinal Numbers in Dates
    By OfficeBitty in forum Excel General
    Replies: 13
    Last Post: 11-21-2006, 05:34 AM
  5. How can I superscript numbers greater than 3?
    By Caseybay in forum Excel General
    Replies: 2
    Last Post: 04-23-2005, 12:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1