1

斜体テキストを強調表示するコード:

Sub Bold_Italic()
    Dim rng As Range
    Set rng = ActiveDocument.Range
    rng.Collapse Direction:=wdCollapseStart

    rng.Find.ClearFormatting
    rng.Find.Font.Italic = True
    rng.Find.Replacement.ClearFormatting
    rng.Find.Replacement.Highlight = True
    rng.Find.Replacement.Font.Color = wdColorRed
    With rng.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    rng.Find.Execute Replace:=wdReplaceAll
End Sub

段落全体を強調表示したり、段落を選択したりするにはどうすればよいですか?
実は、段落ごとにコピーして別の文書に貼り付けたいのです。

4

1 に答える 1

1

私はあなたが探していると信じていますrange.select

Sub Macro()
Dim i As Integer
    For i = 1 To ActiveDocument.Paragraphs.Count
        Dim range As range
        Set range = ActiveDocument.Paragraphs(i).range

        'range.Characters.Count > 1 means there is text in the paragraph
         If range.Characters.Count > 1 Then
         'Handle the desired operation with the paragraph text
            range.Select
            MsgBox (range.Text)
         End If
    Next i
End Sub
于 2012-11-06T06:24:19.637 に答える