Last active
February 18, 2024 09:23
-
-
Save touchiep/ba6fbed83f2da3d34255c348f24b6fb5 to your computer and use it in GitHub Desktop.
[VBA][Word] สำหรับใช้เพื่อแก้ภาษาอังกฤษเป็นภาษาไทยเวลาที่พิมพ์ผิดภาษา สำหรับใช้ใน Word
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub ETCorrection() | |
'For correction miss spelling from English to Thai. | |
Dim i | |
Dim EngChar | |
Dim ThaChar | |
Dim EngArray As Variant | |
Dim ThaArray As Variant | |
EngChar = "1 2 3 4 5 6 7 8 9 0 - = ! @ # $ % ^ & * ( ) _ + q w e r t y u i o p [ ] \ Q W E R T Y U I O P { } | a s d f g h j k l ; ' A S D F G H J K L : "" z x c v b n m , . / Z X C V B N M < > ?" | |
EngArray = Split(EngChar, " ") | |
ThaChar = "ๅ / - ภ ถ ุ ึ ค ต จ ข ช + ๑ ๒ ๓ ๔ ู ฿ ๕ ๖ ๗ ๘ ๙ ๆ ไ ำ พ ะ ั ี ร น ย บ ล ฃ ๐ "" ฎ ฑ ธ ํ ๊ ณ ฯ ญ ฐ , ฅ ฟ ห ก ด เ ้ ่ า ส ว ง ฤ ฆ ฏ โ ฌ ็ ๋ ษ ศ ซ . ผ ป แ อ ิ ื ท ม ใ ฝ ( ) ฉ ฮ ฺ ์ ? ฒ ฬ ฦ" | |
ThaArray = Split(ThaChar, " ") | |
For i = LBound(EngArray) To UBound(EngArray) | |
Selection.Find.ClearFormatting | |
Selection.Find.Replacement.ClearFormatting | |
With Selection.Find | |
.Text = EngArray(i) | |
.Replacement.Text = ThaArray(i) | |
.Forward = True | |
.Wrap = wdFindContinue | |
.Format = False | |
.MatchCase = False | |
.MatchWholeWord = False | |
.MatchKashida = False | |
.MatchDiacritics = False | |
.MatchAlefHamza = False | |
.MatchControl = False | |
.MatchAllWordForms = False | |
.MatchSoundsLike = False | |
.MatchWildcards = False | |
End With | |
Selection.Find.Execute Replace:=wdReplaceAll | |
Next i | |
'MsgBox "Correction completed", vbOKOnly, "Complete" | |
End Sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment