[#VBA Tips] : Code huyển font .VN VNI sang Unicode - QUẢN TRỊ EXCEL

QUẢN TRỊ EXCEL

Chào mừng các bạn đến với QuanTriExcel.info - Không gì là Không thể... Về thủ thuật Excel, học lập trình VBA, phần mềm chuyên dụng, kế toán, kĩ năng sống ...

Search This Blog

Saturday, February 8, 2020

[#VBA Tips] : Code huyển font .VN VNI sang Unicode

[#VBA Tips] : Code huyển font .VN VNI sang Unicode
(Chuyển nhanh font trong MS Project với VBA)

TCVN3 to Unicode

Function TCVN3toUNICODE(vnstr As String) As String
Dim c As String, i As Integer
For i = 1 To Len(vnstr)
c = Mid(vnstr, i, 1)
Select Case c
Case "a": c = ChrW$(97)
Case "¸": c = ChrW$(225)
Case "µ": c = ChrW$(224)
Case "¶": c = ChrW$(7843)
Case "·": c = ChrW$(227)
Case "¹": c = ChrW$(7841)
Case "¨": c = ChrW$(259)
Case "¾": c = ChrW$(7855)
Case "»": c = ChrW$(7857)
Case "¼": c = ChrW$(7859)
Case "½": c = ChrW$(7861)
Case "Æ": c = ChrW$(7863)
Case "©": c = ChrW$(226)
Case "Ê": c = ChrW$(7845)
Case "Ç": c = ChrW$(7847)
Case "È": c = ChrW$(7849)
Case "É": c = ChrW$(7851)
Case "Ë": c = ChrW$(7853)
Case "e": c = ChrW$(101)
Case "Ð": c = ChrW$(233)
Case "Ì": c = ChrW$(232)
Case "Î": c = ChrW$(7867)
Case "Ï": c = ChrW$(7869)
Case "Ñ": c = ChrW$(7865)
Case "ª": c = ChrW$(234)
Case "Õ": c = ChrW$(7871)
Case "Ò": c = ChrW$(7873)
Case "Ó": c = ChrW$(7875)
Case "Ô": c = ChrW$(7877)
Case "Ö": c = ChrW$(7879)
Case "o": c = ChrW$(111)
Case "ã": c = ChrW$(243)
Case "ß": c = ChrW$(242)
Case "á": c = ChrW$(7887)
Case "â": c = ChrW$(245)
Case "ä": c = ChrW$(7885)
Case "«": c = ChrW$(244)
Case "è": c = ChrW$(7889)
Case "å": c = ChrW$(7891)
Case "æ": c = ChrW$(7893)
Case "ç": c = ChrW$(7895)
Case "é": c = ChrW$(7897)
Case "¬": c = ChrW$(417)
Case "í": c = ChrW$(7899)
Case "ê": c = ChrW$(7901)
Case "ë": c = ChrW$(7903)
Case "ì": c = ChrW$(7905)
Case "î": c = ChrW$(7907)
Case "i": c = ChrW$(105)
Case "Ý": c = ChrW$(237)
Case "×": c = ChrW$(236)
Case "Ø": c = ChrW$(7881)
Case "Ü": c = ChrW$(297)
Case "Þ": c = ChrW$(7883)
Case "u": c = ChrW$(117)
Case "ó": c = ChrW$(250)
Case "ï": c = ChrW$(249)
Case "ñ": c = ChrW$(7911)
Case "ò": c = ChrW$(361)
Case "ô": c = ChrW$(7909)
Case "­": c = ChrW$(432)
Case "ø": c = ChrW$(7913)
Case "õ": c = ChrW$(7915)
Case "ö": c = ChrW$(7917)
Case "÷": c = ChrW$(7919)
Case "ù": c = ChrW$(7921)
Case "y": c = ChrW$(121)
Case "ý": c = ChrW$(253)
Case "ú": c = ChrW$(7923)
Case "û": c = ChrW$(7927)
Case "ü": c = ChrW$(7929)
Case "þ": c = ChrW$(7925)
Case "®": c = ChrW$(273)
Case "A": c = ChrW$(65)
Case "¡": c = ChrW$(258)
Case "¢": c = ChrW$(194)
Case "E": c = ChrW$(69)
Case "£": c = ChrW$(202)
Case "O": c = ChrW$(79)
Case "¤": c = ChrW$(212)
Case "¥": c = ChrW$(416)
Case "I": c = ChrW$(73)
Case "U": c = ChrW$(85)
Case "¦": c = ChrW$(431)
Case "Y": c = ChrW$(89)
Case "§": c = ChrW$(272)
End Select
TCVN3toUNICODE = TCVN3toUNICODE + c
Next i
End Function
view rawVBA_TCVN2Uni.bas hosted with ❤ by GitHub

VNI to Unicode

Public Function VniToUni(str$) As String
Dim VNI$, UNI$, i&, sUni$, arrUNI() As String
VNI = "aù,aø,aû,aõ,aï,aâ,aê,aá,aà,aå,aã,aä,aé,aè,aú,aü,aë,AÙ,AØ,AÛ,AÕ,AÏ,AÂ,AÊ,A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EF9,1EF5,DD,1EF2,1EF6,1EF8,1EF4,111,110"
arrUNI = Split(UNI, ",")
For i = 1 To Len(str)
If InStr(VNI, Mid(str, i, 2)) > 0 And Len(Mid(str, i, 2)) = 2 Then
sUni = sUni & ChrW("&h" & arrUNI(InStr(VNI, Mid(str, i, 2)) \ 3))
i = i + 1
ElseIf InStr(VNI, Mid(str, i, 1) & " ") > 0 Then
sUni = sUni & ChrW("&h" & arrUNI(InStr(VNI, Mid(str, i, 1) & " ") \ 3))
End If
If InStr(VNI, Mid(str, i, 1)) = 0 Or InStr("a,A,e,E,o,O,u,U,y,Y, ", Mid(str, i, 1)) > 0 Then sUni = sUni & Mid(str, i, 1)
Next
VniToUni = sUni
End Function
👍Các bạn tải App Quản Trị Excel cài trực tiếp trên điện thoại Iphone và Android mới nhất tại đây : https://www.quantriexcel.info/p/than-gui-cac-ban-tai-quantriexcel.html

No comments:

Post a Comment

Bạn hãy chia sẻ nhận xét ở đây nhé: