如何在Powerpoint VBA中更改格式化日期的语言环境 [英] How to change the locale of a formatted date in Powerpoint VBA
问题描述
在powerpoint vba应用程序中,我想根据当前的拼写检查语言(可能与系统语言环境的语言相同或不相同)格式化日期.
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).
例如语言环境为德语(奥地利),但对于英语客户,该文档为英文,因此日期格式应为"2015年1月1日",而不是"2015年1月1日".
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"
我在此站点上找到了excel的解决方案:如何更改格式化日期的语言环境?
I found a solution for excel on this site: How to change the locale of a formatted date?
在powerpoint vba中尝试相同的技术似乎不起作用:
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忽略方括号中的任何内容.
--> vba ignores whatever is in the square brackets.
有人建议如何在VBA中获得相同的结果吗?
Any suggestions how to achieve the same result within VBA?
推荐答案
存在相同的问题,很难找到解决方案,所以我将回答这个较早的问题:
Had the same problem and it was difficult to find a solution, so I will answer this older question:
使用工具>激活Excel库.参考书目>Microsoft Excel 16.0对象库(或您当前的Excel版本,可能是12.0或14.0)菜单入口激活Microsoft Excel 16.0对象库
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
然后您可以使用此Excel WorksheetFunction:
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
这篇关于如何在Powerpoint VBA中更改格式化日期的语言环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!