我有一个包含大量项目的文档。我已经通过,如果他们是高优先级的话,某些项目是红色字体。
我想创建一个宏,以便Word找到所有红色字体实例,保存这些项目名称,然后将它们粘贴到我文档顶部的列表中。
当我尝试做宏记录器时,这就是我得到的。
Sub HotTopics()
'
' HotTopics Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Font.Color = wdColorRed
With Selection.Find
.Text = ""
.Font.Color = wdColorRed
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Copy
Selection.PasteAndFormat (wdFormatOriginalFormatting)
End Sub
当我尝试运行宏时,它说Selection.copy有错误,因为没有要复制的内容
答案 0 :(得分:0)
录制宏时,您没有单击“查找”。注意倒数第二行。
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchByte = False
.CorrectHangulEndings = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
.MatchFuzzy = False
End With
Selection.Find.Execute
Selection.Copy