Basic Macro - Date NumberFormat

I am trying to insert the date into a letter as part of a larger macro. I would like to format by date “mmmm d, yyyy” (e.g. March 6, 2013). I have the following code which works perfectly except I don’t know the NumberFormat for the desired date format.

Sub Main

Dim Doc As Object
Dim DateTimeField As Object
Dim Cursor As Object
Doc = ThisComponent
Cursor = Doc.Text.createTextCursor()

DateTimeField = Doc.createInstance("com.sun.star.text.textfield.DateTime")
DateTimeField.IsFixed = False
DateTimeField.IsDate = True
DateTimeField.NumberFormat = 84
Doc.Text.insertTextContent(Cursor, DateTimeField, False)

End Sub

The code “84” above will give the date in the ISO8601 format (learned from a random forum post) but not the format I want. The LibreOffice API website lists this optional property but gives no clue as to what the codes are, from what I can tell they are specific only to LibreOffice.

http://api.libreoffice.org/docs/common/ref/com/sun/star/text/textfield/DateTime.html

At this point I have scoured Google with absolutely no success, thanks for any help you can provide.

In the end I wrote a macro that printed all possible values from 1 to 6000. Here is the list of meaningful and unique NumberFormat values. Note some values are not date formats. If you would like the original file and macro, you will have to upvote my answer so I can get enough karma to upload files.

Macro run on March 14, 2013 at 2:29 pm.

10	 = 	4134761%
11	 = 	4134760.39%
20	 = 	$41,348
21	 = 	$41,347.60
24	 = 	41,347.61 USD
30	 = 	3/14/13
31	 = 	Thu 14/Mar 13
32	 = 	03/13
33	 = 	Mar 14
34	 = 	March
35	 = 	1st quarter 13
36	 = 	03/14/2013
38	 = 	Thursday, March 14, 2013
39	 = 	Mar 14, 13
40	 = 	14:29
41	 = 	14:29:38
42	 = 	02:29 PM
43	 = 	02:29:38 PM
44	 = 	992342:29:38
45	 = 	29:38.00
46	 = 	992342:29:38.00
50	 = 	03/14/13 02:30 PM
51	 = 	03/14/2013 14:30:00
60	 = 	4.13E+004
61	 = 	4.13E+04
70	 = 	41347 3/5
71	 = 	41347 26/43
72	 = 	41347 2/4
73	 = 	41347 60/100
75	 = 	Mar 14, 2013
76	 = 	March 14, 2013
77	 = 	Thu, Mar 14, 13
78	 = 	Thu, March 14, 2013
79	 = 	Thursday, March 14, 2013
80	 = 	14. Mar. 2013
81	 = 	14. March 2013
82	 = 	03-14
83	 = 	13-03-14
84	 = 	2013-03-14
99	 = 	TRUE
110	 = 	Thu Nissan 3 5773
111	 = 	Thu 3 Nissan 5773
112	 = 	3 Nissan 5773
113	 = 	Nissan 3 5773
114	 = 	3 Nissan
115	 = 	Nissan 3
116	 = 	Nissan 5773
117	 = 	Nissan

I needed this because the Record Macro function of insert with formatted date failed miserably. This saved my bacon. thanks.

This question/answer is a prime example of how the LibreOffice Forum “karma” system is counterproductive. I would very much liked to have seen the macro that was used to produce the output above, but I don’t have enough “karma” points to upvote the answer as suggested by the poster so he could upload the code. So, six years later, nobody has seen the method that was used and nobody has gotten any smarter.