this should work for you uses wildcards
or maybe even better .. finds #sub that is a specific color
Word.Find f=app.Selection.Find
f.ClearFormatting
f.Text="#sub *"
f.MatchWildcards = 1
rep
,if(!f.Execute)
,,break
,app.Selection.ParagraphFormat.Borders.Item(wdBorderTop).LineStyle = wdLineStyleSingle
or maybe even better .. finds #sub that is a specific color