0

in a powerpoint vba application I want to format a date according to the current spell-check language (which may or may not be the same as the system locale language).

e.g. Locale is German(Austria) but the document is in English for an english customer, hence the date format should be "1st January 2015" and not "01. Jänner 2015"

I found a solution for excel on this site: How to change the locale of a formatted date?

trying the same technique in powerpoint vba does not appear to work:

debug.print format (now(), "[$-415] MMMM")
 Jänner

debug.print format (now(), "[$-809] MMMM")
 Jänner

debug.print format (now(), "[any old rubbish] MMMM")
 Jänner

--> vba ignores whatever is in the square brackets.

Any suggestions how to achieve the same result within VBA?

Community
  • 1
  • 1
mfh8010
  • 1
  • 1
  • I don't see any direct way of doing this; perhaps pass Format(Now,"mm") and the LangID you want off to a function that looks up the return value from an array of month names that you provide, then build the rest of the date string from there. Reasonable if you only need to support a few languages and easy enough to add more to. Not so reasonable if the answer to "What languages must you support?" is "All of them" – Steve Rindsberg Jan 13 '15 at 15:34
  • seems wrong to write my own array of month names when MS already did the work.... – mfh8010 Jan 13 '15 at 17:25
  • ...i can add a date placeholder on the header/footer - and i can change the locale for the date display via the dialog box...so all i would need to do is replicate this programmatically. But i can´t find out where to do this...and strangely this dialog doesn´t respond to changes in the Office language settings or the locale (default is US-English even after deleting this as an option in the Language preferences dialog). – mfh8010 Jan 13 '15 at 17:37
  • "seems wrong to write my own array of month names when MS already did the work.... " Seems wrong that they don't expose it to us. But since they didn't ... – Steve Rindsberg Jan 14 '15 at 02:13

1 Answers1

0

Had the same problem and it was difficult to find a solution, so I will answer this older question:

Activate the Excel Library with Tools > References > Microsoft Excel 16.0 Object Library (or your current Excel version, might be 12.0 or 14.0) Menu entrance Activate Microsoft Excel 16.0 Object Library

Then you can use this Excel WorksheetFunction:

Debug.Print WorksheetFunction.Text(Now, "[$-409]MMMM")

You can even even specify it with further parameters like different calendars, a list of of locale codes can be found here: https://stackoverflow.com/questions/54134729