Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

format of date insert in word

Status
Not open for further replies.

99mel

Programmer
Joined
Oct 18, 1999
Messages
379
Location
GB
Can i include the 'th', 'st', 'rd' after the date (dd)?

The nearest format available to choose is '30 May 2002'
Can i have it so its '30th May 2002'?
 
If it was a simple matter of adding just the th, it's easy. But since you have st, nd and rd also, you would probably have to use VBA.

Indu
 
can i easily implement it in vba then? so when the document opens the specfic letters are added?
 
You will have to test the cell for the date and then depending on the whether it is 1, 2, 3, 21, 22, 23 ,31 or other; you will have to include a statement similar to

Selection.NumberFormat = "dd""th""-mmm-yy"

replacing th with st, nd and rd

HTH

Indu
 
Profuse apologies.

I was working under Excel mode. I beg your pardon.

Back to the drawing board.

Indu
 
Loking for redemption.

This macro will do what you are looking for.

Sub dtmacro()

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="DATE \@ ""d"" \* ordinal", PreserveFormatting:=True
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="DATE \@ "" MMMM yyyy""", PreserveFormatting:=True


End Sub

HTH

Indu
 
Is this adding a new date time field?

ummm, if so where?

So if i make this macro and run it when the document loads up?

cheers for ya help.
 
It puts today's date at cursor position. So, I guess it would put it at the top left if it's part of auto_open.

Indu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top