0
私はMS Word文書内の特定の単語を見つけるためにRegEx検索を使用しています。検索結果は変数に格納されます。私の問題は、検索結果のみにカスタムスタイルを適用したいということです。特定の単語にスタイルを適用する
入力: [1,2]。 [1,3,4] [1,2,4,5] [1,2,6,7,8] [1,2] [1,2]
の前、中または後に次のコード
Sub RegexReplaces()
Set matches = New regExp
Dim Sure As Integer
Dim rng As Range
matches.Pattern = "([\[\(][0-9, -]*[\)\]])"
matches.Global = True
Dim mat As MatchCollection
Set mat = matches.Execute(ActiveDocument.Range)
For Each m In mat
Sure = MsgBox("Are you sure?" + m, vbOKCancel)
If Sure = 1 Then
m.Style = ActiveDocument.Styles("Heading 1") 'this is the error line
Else
MsgBox "not1111"
End If
Next m
End Sub
私は本当にこれを行う方法について心配していたので、お返事ありがとうございました。この答えは私には大いに意味します。 – Kevin
私は助けることができてうれしいです!私の答えを受け入れてくれてありがとう。 –