locked
Insert Persian Text from a file into PowerPoint using VBa RRS feed

  • Question

  • Hello,

    I am trying to read a plaintext store as UTF-8 and split it into slides in PowerPoint. However, my text doesn't work. Persian is a subset of Arabic typesetting codes.

    Function convertANSIPersian2Unicode(inputStr As String) As String
        Dim n As Integer
        Dim i As Integer
        Dim inBytes() As Byte
        Dim sUnicode As String
        
        ' Convert input string to byte array
        n = Len(inputStr)
        ReDim inBytes(n + 1)
        
        For i = 1 To n
            inBytes(i) = AscB(Mid(inputStr, i, 1))
        Next
        
        ' Convert byte array to unicode using Persian coding
        sUnicode = StrConv(inBytes, vbUnicode, &H429)
        
        ' remove starting null
        iPos = InStr(sUnicode, Chr(0))
        If iPos > 0 Then sUnicode = Mid(sUnicode, iPos + 1)
        
        convertANSIPersian2Unicode = sUnicode
    
    End Function

    Now when I write

    pptTable.Table.Cell(1, Count Mod 2).Shape.TextFrame.TextRange.Text = convertANSIPersian2Unicode(DataLine)

    The text is a gibberish mix of Arabic characters with special chars.

    I have Widnows 10 set to show Persian text.

    Any help would be greatly appreciated.

    Sunday, November 29, 2020 11:18 PM