Forum Discussion

JoeChbat's avatar
JoeChbat
Copper Contributor
Mar 31, 2020

Arabic VBA code not working - even after changing Unicode

Hello All,

 

I have typed a code that spells numbers in Arabic and the code is still not working properly.

I could read it fine in the VBA at first, then when its in the formula cell, it shows strange characters not related to Arabic or question marks  "??????????"

 

 

  • msamyGawad's avatar
    msamyGawad
    Copper Contributor

    JoeChbat

    المشكلة قابلتني في الscripting
    ولكن في برنامج الاكسيل
    VBA Excel
    المشكلة كانت مقبلاني في ويندوز 10
    والمشكلة ليها علاقة بالويندوز اوتحديد باصداره
    الحل الي اشتغل معايا انك تعدل وضع ال
    region
    ولكن من اعدادات الويندوز الجديدة
    مش من ال
    control panel
    بالترتيب كدة

    1. start menu
    2. Setting (Gear icon)
    3. Time & Language
    4. Region
    5. Chane Regional Format to Arabic

    بعد كدة هتعمل نفس القصة بس من الكنترول بانل

    • Control panel
    • search box (region)
    • select first result
    • select "Administrative" Tab
    • click "Change System Local button"
    • choose Arabic language
    • then check the "Check box" beneath it which is labeled as "Beta : Use Unicode UTF-8 for worldwide language support"

    then click "Ok" button and restart PC
    بعد ما تفتح هتعمل الاتي 

    • Start menu
    • setting (Gear icon)
    • time and language
    • language
    • click on the arabic language and move it up to be the first
    • then restart the PC again

    بعدها هتجرب برنامج ال

    VBA

    الملحق بالاوفيس سواء بقي في الاكسيل او الاكسس
    هتجرب بس انك تعمل ماكرو صغير كدة يعرض كلام عربي في

    msg box

    زي التالي كدة

    public trial ()
    
    msgbox "بسم الله الرحمن الرحيم"
    
    end sub

     

    وده مثال للتجربة في

    Excel VBA
    وبكدة يكون الدنا تمام واتحلت المشكلة الحمد لله
    جرب في ملفك الاساسي الي انت شغال فيه وعدل في الكود واحفظه وعدل في النص العربي واحفظه واقفل الملف وافتحه تاني وبعدها جرب ان شاء الله يشتغل

    ولو مشتغلتش
    انقل الاسكربت في ملف جديد وجربه..

    • khaledthabet's avatar
      khaledthabet
      Copper Contributor

      msamyGawad اشكرك جزيلا على الحل الذى اوجدتة - ادام الله عليك علمك وزادك منة وجزاك عنا خيرا

    • SarahIhab's avatar
      SarahIhab
      Copper Contributor

      msamyGawad 

      انا غيرت ال settings

      عندى زى الcomment

      الى حضرتك كتبته و ال excel

      بقى بيقرا العربى فعلا شكرا.

       

      المشكله بقى ان ال vba

      بيعمل output للعربى 

      بعلامات استفهام مع انى عيرت الfont

      يبقى مكتوب جنبه عربى و ده الحل الى لقيته لما عملت search

       

        

      ده output

      عربى ال excel 

       

       

      و ده output 

      ال vba

      • msamyGawad's avatar
        msamyGawad
        Copper Contributor

        SarahIhab 
        الموضوع كدة غريب فعلا
        مش عارف كدة بسبب ايه الحقيقة
        بس لو قفلت خالص ممكن تكتبي ال
        Unicode
        بتاع الكلمة نفسها
        بتحولي النص علي اي موقع اونلاين زي ده مثلا
        http://mylanguages.org/converter.php
        كمثال
        بسم الله الرحمن الرحيم
        هتبقي
        بسم الله الرحمن الرحيم

    • asherif635's avatar
      asherif635
      Copper Contributor

      الأخ الكريم حاولت بكافة الاشكال و لا المعادلة لا تعمل و يعطي ؟؟؟msamyGawad 

      • msamyGawad's avatar
        msamyGawad
        Copper Contributor

        asherif635 

        كدة ممكن يكون مشكلة مختلفة بسبب اثدار ويندوز تاني خالص

        مش هقدر افيدك، بعتذر

  • Diaabbsf's avatar
    Diaabbsf
    Copper Contributor
    Beta: Use Unicode UTF-8 for worldwide language support (UNCHECK)
    in the Administrative Region Sitting
    • raidmahbouba's avatar
      raidmahbouba
      Copper Contributor

      Diaabbsf 
      Thank you Diaab,
      It is checked already!

      The problem is with MS Office 365, because the VB code is still running in my old computer that has MS Office 10!

  • JoeChbat 

     

    Could you please attached the sample file 

     

    Regards, Faraz Shaikh | MCT, MIE, MOS Master, Excel Expert

    If you find the above solution resolved your query don't forget mark as Official Answer.

      • HI JoeChbat 

         

        Thanks for your feedback, could you please share what changes have you made.. it will be helpful for the community to learn from your experience

         

        Regards, Faraz Shaikh | MCT, MIE, MOS Master, Excel Expert

        If you find the above solution resolved your query don't forget mark as Official Answer.

    • raidmahbouba's avatar
      raidmahbouba
      Copper Contributor
      Me too the text appears like question mark(?) inside a blackbox stands on its corner!
      I tried changing the settings inside the developer and the settings of controlpanel!
      The code was perfectly working in the 2013 MS office, but the latest version of MS office does not support the conversion of number to texts.
      using this code:
      Function NumberToTextEN(ByVal MyNumber, MainCurrency As String, SubCurrency As String)

      Dim Number1, Number2, Temp

      Dim DecimalPlace, Count

      ReDim Place(9) As String

      Place(2) = " Thousand "

      Place(3) = " Million "

      Place(4) = " Billion "

      Place(5) = " Trillion "

      MyNumber = Trim(str(MyNumber))

      DecimalPlace = InStr(MyNumber, ".")

      If DecimalPlace > 0 Then

      Number2 = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & "00", 2))

      MyNumber = Trim(Left(MyNumber, DecimalPlace - 1))

      End If

      Count = 1

      Do While MyNumber <> ""

      Temp = GetHundreds(Right(MyNumber, 3))

      If Temp <> "" Then Number1 = Temp & Place(Count) & Number1

      If Len(MyNumber) > 3 Then

      MyNumber = Left(MyNumber, Len(MyNumber) - 3)

      Else

      MyNumber = ""

      End If

      Count = Count + 1

      Loop

      Select Case Number1

      Case ""

      Number1 = "Zero " & MainCurrency

      Case Else

      Number1 = Number1 & " " & MainCurrency

      End Select

      Select Case Number2

      Case ""

      Number2 = ""

      Case Else

      Number2 = " and " & Number2 & " " & SubCurrency

      End Select

      NumberToTextEN = Number1 & Number2

      End Function



      Function GetHundreds(ByVal MyNumber)

      Dim Result As String

      If Val(MyNumber) = 0 Then Exit Function

      MyNumber = Right("000" & MyNumber, 3)

      If Mid(MyNumber, 1, 1) <> "0" Then

      Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "

      End If


      If Mid(MyNumber, 2, 1) <> "0" Then

      Result = Result & GetTens(Mid(MyNumber, 2))

      Else

      Result = Result & GetDigit(Mid(MyNumber, 3))

      End If

      GetHundreds = Result

      End Function



      Function GetTens(TensText)

      Dim Result As String
      Result = ""

      If Val(Left(TensText, 1)) = 1 Then

      Select Case Val(TensText)

      Case 10: Result = "Ten"

      Case 11: Result = "Eleven"

      Case 12: Result = "Twelve"

      Case 13: Result = "Thirteen"

      Case 14: Result = "Fourteen"

      Case 15: Result = "Fifteen"

      Case 16: Result = "Sixteen"

      Case 17: Result = "Seventeen"

      Case 18: Result = "Eighteen"

      Case 19: Result = "Nineteen"

      Case Else

      End Select

      Else

      Select Case Val(Left(TensText, 1))

      Case 2: Result = "Twenty "

      Case 3: Result = "Thirty "

      Case 4: Result = "Forty "

      Case 5: Result = "Fifty "

      Case 6: Result = "Sixty "

      Case 7: Result = "Seventy "

      Case 8: Result = "Eighty "

      Case 9: Result = "Ninety "

      Case Else

      End Select

      Result = Result & GetDigit(Right(TensText, 1))

      End If

      GetTens = Result

      End Function



      Function GetDigit(Digit)

      Select Case Val(Digit)

      Case 1: GetDigit = "One"

      Case 2: GetDigit = "Two"

      Case 3: GetDigit = "Three"

      Case 4: GetDigit = "Four"

      Case 5: GetDigit = "Five"

      Case 6: GetDigit = "Six"

      Case 7: GetDigit = "Seven"

      Case 8: GetDigit = "Eight"

      Case 9: GetDigit = "Nine"

      Case Else: GetDigit = ""

      End Select

      End Function