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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calendar Date Format 1

Status
Not open for further replies.
Dec 24, 2001
857
GB
I'm creating a form in Word 2002 and part of the form uses the calendar. My bookmarks in Word are working correctly and when you press the submit button, all the data is entered.

However, after looking up on the internet \ Word helpfiles and trying several attempts at the date format, it still enters it as dd/mm/yy. I'd really only like to have the full month and year displayed e.g. 'October 2005'. Whats the correct code for changing the date format, and at what stage would this have to be done?

The code which gets the date is:

Code:
calendarDate = ocxCalendar.Value

and to enter it to the form:

Code:
ActiveDocument.Bookmarks("date").Range.InsertBefore calendarDate

I've deliberately missed out all the code I've tried for formatting the date because there was so much!


The other thing is I'm using 'InsertBefore' but really I'd like it to replace whatever is currently in the book mark - what code would I use to do this?

Thanks
 
The following works for me:
Code:
ActiveDocument.Bookmarks("UserDate").Range.InsertBefore Format(CalendarDate, "mmmm, yyyy")

I'm assuming the calendarDate variable is declared as a Date.

You might also want to check out this recent thread concerning date handling/formatting: thread707-1132692

I don't program in Word much so can't help with the second part but others will likely weigh in.


Regards,
Mike
 
cheers that seems to work - its similar to some code I tried, but the stuff I was working on said you had to surround the mmmm yyyy with []. oh, and it missed out the comma. anyway that looks fine so now I just have to figure out the other part. thanks for your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top