2017-07-06 142 views
0

試圖讓這個宏遍歷所有段落,並檢查它們是否以數字開頭,如果是的話,我希望它使所有該段落爲粗體。 但是,沒有任何反應,甚至沒有發生錯誤信息。Word VBA - 粗體段落如果第一個字符是數字

Sub titles() 

    For Each Paragraph In ActiveDocument.Paragraphs 
     If IsNumeric(Paragraph.Range.Words(1).Characters(1)) = True Then 
      wcount = Paragraph.Range.Words.Count 
      Paragraph.Range.Words(wcount).Font.Bold = True 
      'MsgBox (wcount) 
     End If 
    Next Paragraph 

End Sub 

回答

3

此:

Paragraph.Range.Words(wcount).Font.Bold = True 

只會大膽的最後一個 「字」。嘗試:

Paragraph.Range.Font.Bold = True 
+0

工程就像一個魅力! – Serveira