1

数値形式を変更できません。RegExp を使用して doc ファイルから数値を読み取りますが、形式は変更しません。コメント行が問題です。

Sub ChangeNumberFormat()

Dim SectionText As String
Dim RegEx As Object, Matches As Object, Match As Object
Dim i As Integer

Set RegEx = CreateObject("vbscript.regexp")
With RegEx
    .Global = True
    .MultiLine = False
    .Pattern = "(\d{1,3}\s(\d{3}\s)*\d{3}(\,\d{1,3})?|\d{1,3}\,\d{1,3})"
End With

For i = 1 To ActiveDocument.Sections.Count()
    SectionText = ActiveDocument.Sections(i).Range.Text
    If RegEx.Test(SectionText) Then
        Set Matches = RegEx.Execute(SectionText)

        For Each Match In Matches
            **Match = Format(Match, "##,##0.00")**
            MsgBox Match
        Next

        Set MsgMatches = Nothing
        Set    Match = Nothing
     End If
  Next

Set RegEx = Nothing
End Sub
4

0 に答える 0