こんにちは。
このパターンが『<ゴ>と<ミ>』が、本当に、正しければ、以下のようなコードでできるはずです。ただ、半角であったりしたら、パターンを書き換える必要があります。
'----------------------------------------------------
Sub PickupWordChangFormat()
Dim objRegExp As Object
Dim mySelection As Selection
Dim Matches As Object
Dim Match As Object
Dim myWords() As String
Dim i As Long
Set objRegExp = CreateObject("VBscript.RegExp")
Selection.HomeKey Unit:=wdStory
Selection.EndKey Unit:=wdStory, Extend:=wdExtend
Set mySelection = Selection
With objRegExp
.Global = True
.IgnoreCase = True
'ここのパターンで検索が決まります。
.Pattern = "<ゴ>([^<]+)<ミ>"
Set Matches = .Execute(mySelection)
For Each Match In Matches
ReDim Preserve myWords(i)
myWords(i) = .Replace(Match.Value, "$1")
i = i + 1
Next Match
End With
For i = LBound(myWords) To UBound(myWords)
s_WordFinding myWords(i)
Next
Selection.HomeKey Unit:=wdStory
End Sub
Sub s_WordFinding(ByVal myString As String)
Dim myRange As Range
Selection.Find.ClearFormatting
With Selection.Find
.Text = myString
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
End With
Selection.Find.Execute
Set myRange = Selection.Range
s_FormatChanging myRange
End Sub
Sub s_FormatChanging(ByVal myRange As Range)
With myRange
'書式変更部分
.Font.Bold = True '太字
.Font.ColorIndex = wdBlue '青
End With
End Sub
お礼
できました!! どうもありがとうございました。 これで、仕事の能率が400%アップします。 また、なにかありましたら、教えてGOOださい。(^。^)