Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用Excel VBA获取阿拉伯月份名称_Vba_Excel_Arabic_Right To Left - Fatal编程技术网

如何使用Excel VBA获取阿拉伯月份名称

如何使用Excel VBA获取阿拉伯月份名称,vba,excel,arabic,right-to-left,Vba,Excel,Arabic,Right To Left,在ExcelVBA中,我试图将“一个月的阿拉伯名称”放入变量中,我找到了一种方法。但我的方法需要一个缓冲单元格,以便在其中放置值、更改单元格格式、检索单元格的文本值,然后将该值放入变量中 以下是我的VBA代码: Sub GetArabicName() Sheets("Sheet1").Cells(1, 1).Value = date() Sheets("Sheet1").Cells(1, 1).NumberFormat = "[$-10A0000]m

在ExcelVBA中,我试图将“一个月的阿拉伯名称”放入变量中,我找到了一种方法。但我的方法需要一个缓冲单元格,以便在其中放置值、更改单元格格式、检索单元格的文本值,然后将该值放入变量中

以下是我的VBA代码:

    Sub GetArabicName()
         Sheets("Sheet1").Cells(1, 1).Value = date() 
         Sheets("Sheet1").Cells(1, 1).NumberFormat = "[$-10A0000]mmmm;@" 
         ArabicMonth = Sheets("Sheet1").Cells(1, 1).Text
         MsgBox ArabicMonth & " The Arabic Name of the Month"
    End Sub
是否有一种更简单的方法可以使用VBA而不使用缓冲区单元?另外,如何使
MsgBox
显示的阿拉伯语值不是“??”

提前谢谢。

我无法消除对帮助器单元格的需要,但这会得到一个消息类型框来显示文本:

Public Declare Function MessageBoxU Lib "user32" Alias "MessageBoxW" _
                            (ByVal hwnd As Long, _
                             ByVal lpText As Long, _
                             ByVal lpCaption As Long, _
                             ByVal wType As Long) As Long

Sub GetArabicName()
    Dim ArabicMonth As String
    With Sheets("Sheet1").Cells(1, 1)
         .Value = Date
         .NumberFormat = "[$-10A0000]mmmm;@"
         .Font.Name = "Arial Unicode MS"
         ArabicMonth = .Text
    End With
    MessageBoxU 0, StrPtr(ArabicMonth), StrPtr("MsgBox Substitute"), 0
    MsgBox ArabicMonth & " The Arabic Name of the Month"
End Sub

改编自:

编辑#1:

根据Axel Richter的优秀建议,这样就不需要辅助细胞:

Sub GetArabicNames_II()
    Dim ArabicMonth As String
    ArabicMonth = Application.WorksheetFunction.Text(Date, "[$-10A0000]mmmm;@")
    MessageBoxU 0, StrPtr(ArabicMonth), StrPtr("MsgBox Substitute"), 0
End Sub

使用
ArabicMonth=Application.Text(日期,[$-10A0000]mmmm”)
无需缓冲单元
A1