Skip to content

Instantly share code, notes, and snippets.

@weeix
Last active November 27, 2017 06:44
Show Gist options
  • Save weeix/67e4670e6973822d4cdd774c35589f2b to your computer and use it in GitHub Desktop.
Save weeix/67e4670e6973822d4cdd774c35589f2b to your computer and use it in GitHub Desktop.
Macro ชุดนี้มีไว้แก้ไขเลขอารบิก (0-9) ในเอกสารทั้งหมดให้เป็นเลขไทย (๐-๙) เหมาะกับเอกสารที่จัดทำโดยใช้ฟอนต์ TH SarabanIT๙ หรือ TH NiramitIT๙ และต้องการเปลี่ยนกลับมาใช้ฟอนต์มาตรฐาน (ทดสอบกับ LibreOffice 5.4.3.2 แล้ว)
Sub Main
Dim arabicNumerals(10) As String
Dim thaiNumerals(10) As String
Dim n As Long
Dim oDocument As Object
Dim oReplace As Object
arabicNumerals() = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
thaiNumerals() = Array("๐", "๑", "๒", "๓", "๔", "๕", "๖", "๗", "๘", "๙")
oDocument = ThisComponent
oReplace = oDocument.createReplaceDescriptor
For n = lbound(arabicNumerals()) To ubound(arabicNumerals())
oReplace.SearchString = arabicNumerals(n)
oReplace.ReplaceString = thaiNumerals(n)
oDocument.replaceAll(oReplace)
Next n
End Sub
Sub Main
Dim arabicNumerals(10) As String
Dim thaiNumerals(10) As String
Dim n As Long
Dim oDocument As Object
Dim oReplace As Object
arabicNumerals() = Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
thaiNumerals() = Array("๐", "๑", "๒", "๓", "๔", "๕", "๖", "๗", "๘", "๙")
oDocument = ThisComponent
oReplace = oDocument.createReplaceDescriptor
For n = lbound(thaiNumerals()) To ubound(thaiNumerals())
oReplace.SearchString = thaiNumerals(n)
oReplace.ReplaceString = arabicNumerals(n)
oDocument.replaceAll(oReplace)
Next n
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment