Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 突出显示段落_Vba_Ms Word - Fatal编程技术网

Vba 突出显示段落

Vba 突出显示段落,vba,ms-word,Vba,Ms Word,突出显示斜体文本的代码: 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.Rep

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

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
如何突出显示整个段落或为段落选择?

实际上,我想逐段复制并粘贴到另一个文档中。

我相信您正在查找
范围。选择

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

我相信您正在查找
范围。请选择

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