PDA

View Full Version : Convert Short Date to Long Date



DavG63
01-19-2016, 01:42 AM
Hi all

This is hopefully a really simple thing, but I've hit a stumbling block in trying to puzzle it out.

I have a ComboBox on a userform in Word, which is used as (1) the end date for calculation of interest (this bit works perfectly) and (2) dating the letter.

For calculation of the interest, the date needs to be entered in format:- "dd/mm/yyyy", however when dating the letter it needs to display in long form, i.e. "Day Month Year".

I have attempted to define DateofLetter as String, and then put the following into the code controlling the commandbutton to run the macro.


DateofLetter = Format(Me.ComboBox3.Value, "Long Date")

However that doesn't seem to work.

Does anyone know how to go about converting the short date into long date?

Thanks very much

Dav

DavG63
01-19-2016, 01:59 AM
Ah ha! Success - rather than code the conversion in VBA, I just changed the formatting of the DocVariable that displays it in the document. Problem solved!

gmaxey
01-20-2016, 01:35 PM
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oDate As Date, strDate As String
oDate = "1/20/2016"
strDate = Format(oDate, "long date")
lbl_Exit:
Exit Sub
End Sub