【问题标题】:Highlight paragraph突出段落
【发布时间】:2015-03-30 02:43:33
【问题描述】:

突出显示斜体文本的代码:

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

如何突出显示整个段落或使段落被选中?
实际上,我想逐段复制并粘贴到另一个文档中。

【问题讨论】:

    标签: vba ms-word


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-04
      • 2017-05-24
      • 2012-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-21
      • 1970-01-01
      相关资源
      最近更新 更多