以前、似たような質問があったときに興味があり、テキストとして保存
してあるWord用のマクロがあります。回答者が誰だか忘れてたことと、
質問ナンバーを控えていなかったので、過去ログで検索しても探すこと
が出来ませんでした(たぶんどこかにあるはず)。
以下のマクロは、その当時掲載されたままのものですので質問内容とは
少し違うものかもしれませんが参考になると思います。
'*************************ここから***************************
Sub ChgToArabic()
Dim i, LNGT, Kanji, N, LL, L, K, SARABIC
Const Kansuu = "一二三四五六七八九〇"
Const Suuji = "1234567890"
Selection.HomeKey Unit:=wdStory
Perform: Selection.Find.ClearFormatting
With Selection.Find
.Text = "第*条"
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchFuzzy = False
.MatchWildcards = True
End With
If Selection.Find.Execute = False Then Exit Sub
LNGT = Selection.Characters.Count
Selection.Characters.Last.Select
Selection.MoveLeft Unit:=wdCharacter, Count:=LNGT - 1
Selection.MoveRight Unit:=wdCharacter, Count:=LNGT - 2, Extend:=wdExtend
Kanji = Selection.Characters.Parent
LL = Len(Kanji)
SARABIC = ""
L = 0
CHG: L = L + 1
N = Mid(Kanji, L, 1)
Select Case N
Case Is = "一", "二", "三", "四", "五", "六", "七", "八", "九", "〇"
K = Mid(Suuji, InStr(Kansuu, N), 1)
Case Is = "十", "百"
If L = 1 Then
K = "1"
SARABIC = SARABIC & K
GoTo EXT
End If
Select Case Mid(Kanji, L - 1, 1)
Case Is = "一", "二", "三", "四", "五", "六", "七", "八", "九"
GoTo EXT
Case Else
Select Case Mid(Kanji, L + 1, 1)
Case Is = "十", "百"
If N = "十" Then K = "1"
If N = "百" Then K = "1"
Case Is = "一", "二", "三", "四", "五", "六", "七", "八", "九"
If N = "十" Then K = "1"
If N = "百" Then K = "10"
Case Else
If N = "十" Then K = "10"
If N = "百" Then K = "100"
End Select
SARABIC = SARABIC & K
GoTo CHG
End Select
Case Else
K = N
End Select
SARABIC = SARABIC & K
If L < LL Then GoTo CHG
Selection = SARABIC
Selection.MoveRight Unit:=wdCharacter, Count:=1
GoTo Perform
Exit Sub
EXT: Select Case N
Case Is = "十"
Select Case Mid(Kanji, L + 1, 1)
Case Is = "一", "二", "三", "四", "五", "六", "七", "八", "九"
K = ""
Case Else
K = "0"
End Select
Case Is = "百"
Select Case Mid(Kanji, L + 1, 1)
Case Is = "十"
K = ""
Case Is = "一", "二", "三", "四", "五", "六", "七", "八", "九"
Select Case Mid(Kanji, L + 2, 1)
Case Is = "十"
K = ""
Case Else
K = "0"
End Select
Case Else
K = "00"
End Select
End Select
SARABIC = SARABIC & K
If L < LL Then GoTo CHG
Selection = SARABIC
End Sub
'*************************ここまで***************************
これは「第一条」などの条文の箇条部分を変換するものですので、質問
の内容からは少し違うものかもしれませし、「百九十九条」までを対象に
しているものなので少し手直しが必要でしょうが、参考になるのでは。
お礼
どうもありがとうございます。 これは、ずぶの素人の私でも使えそうです。 感謝いたします。