MS Word 将 OutlineDemote 设置为特定单词后的文本
MS Word set OutlineDemote to text after specific word
我想将word文件中特定单词后的整个文本设置为OutlineDemote。
我的 VBA 脚本正在将整个文档设置为 OutlineDemote。
我做错了什么?
Sub FormatFeatures()
Dim myRange As Range
Set myRange = ActiveDocument.Content
myRange.Find.Execute FindText:="Test", _
Forward:=True
If myRange.Find.Found = True Then
myRange.SetRange (myRange.End), ActiveDocument.Content.End
myRange.Paragraphs.OutlineDemote
End If
End Sub
找到的范围的结尾在一个段落内。因此,您需要从以下段落的开头开始您正在使用的范围:
Sub FormatFeatures()
Dim myRange As Range
Set myRange = ActiveDocument.Content
myRange.Find.Execute FindText:="Test", _
Forward:=True
If myRange.Find.Found = True Then
myRange.SetRange myRange.Next(wdParagraph).Start, ActiveDocument.Content.End
myRange.Paragraphs.OutlineDemote
End If
End Sub
编辑:
结果截图
我想将word文件中特定单词后的整个文本设置为OutlineDemote。
我的 VBA 脚本正在将整个文档设置为 OutlineDemote。
我做错了什么?
Sub FormatFeatures()
Dim myRange As Range
Set myRange = ActiveDocument.Content
myRange.Find.Execute FindText:="Test", _
Forward:=True
If myRange.Find.Found = True Then
myRange.SetRange (myRange.End), ActiveDocument.Content.End
myRange.Paragraphs.OutlineDemote
End If
End Sub
找到的范围的结尾在一个段落内。因此,您需要从以下段落的开头开始您正在使用的范围:
Sub FormatFeatures()
Dim myRange As Range
Set myRange = ActiveDocument.Content
myRange.Find.Execute FindText:="Test", _
Forward:=True
If myRange.Find.Found = True Then
myRange.SetRange myRange.Next(wdParagraph).Start, ActiveDocument.Content.End
myRange.Paragraphs.OutlineDemote
End If
End Sub
编辑: 结果截图