Formatting Dates

A

axeman

Hello all,

When I run the code below the date format still comes out as mm/dd/yy
instead of the specified mmmm d, yyyy format. Why is that? Is there some kind
of rule against formatting when using the Date() or Now() functions? Is there
a work around to it. I can't just set the actual field on template to be a
Date field because it holds a strings as well as the date. Any suggestions?

Code Sample:
Dim ReturnDate As String

ReturnDate = DateAdd("w", 7, Date)
ActiveDocument.FormFields("ReturnDate").Result = Format(ReturnDate, "mmmm d,
yyyy")
 
D

Doug Robbins

Works fine for me as long as the ReturnDate formfield is a Text FormField.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
A

axeman

That just goes to show that I'm not paying attention. I had the code right
but I was using the ReturnDate variable in another location of the document
without formatting it before use. I had only formatted it when I set the
result of the formfield. Got it worked out now!

Thanks,
Axe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top