【问题标题】:How to get months in German in VBA?如何在 VBA 中获得德语月份?
【发布时间】:2020-05-24 06:29:17
【问题描述】:

我需要我的代码来创建一个以德语月份命名的文件夹: 不是 3 月 5 日 但 05 月 5 日

Dim strMonth  As String
 strMonth =  Format(Date, "mm")
 ' Check for month folder and create if needed
If Len(Dir("C:\Users\Luca\Desktop\TestDaty\" & client & "\" & Year(Date) & "\" & strMonth & " " & MonthName(Month(Date), False), vbDirectory)) = 0 Then
    MkDir "C:\Users\Luca\Desktop\TestDaty\" & client & "\" & Year(Date) & "\" & strMonth & " " & MonthName(Month(Date), False)
End If

所以也许这里有一些国家代码? 月名(月(日) 请帮我!!! :)

【问题讨论】:

  • 您可以将所有英语月份和对应的德语月份的翻译存储为字典中的键:值对。然后做month_in_german = dict(month).

标签: excel vba


【解决方案1】:

如果您的语言环境设置为德语,我想像 Format(Date, "mmmm") 这样的东西应该可以(对我有用)。否则,如果您只需要创建德语命名文件夹,您可以将语言代码 (LCID) 与 WorksheetFunction.Text() 结合使用:

WorksheetFunction.Text(Date, "[$-407]mmmm")

其中[$-407]language-code 以返回德国月份名称!

【讨论】:

  • 非常感谢您的快速答复!!! strMonth = WorksheetFunction.Text(Date, "[$-407]mmmm") 非常适合我!
  • 仅供参考您可能有兴趣查看Create a calendar input in VBA-Excel的相关多语言功能
猜你喜欢
  • 2020-10-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多