如何搜索文本並在word文檔中檢查相同的文本以進行下劃線。 任何人都可以幫我嗎?如何搜索文本並檢查VBA中的下劃線字
Sub Underline()
Dim fnd As String
Dim n As Long
fnd = InputBox("Enter text to search" & vbCr & vbCr _
& "Click OK to search the entire workbook for all instances of the search text.")
Dim x As Integer
x = 0
Do While x = 0
With Selection.Find
.ClearFormatting
End With
If fnd = False Then
x = 1
Exit Do
End If
Selection.Find.Execute
If .Underline = False Then
Selection.Comments.Add Range:=Selection.Range, Text:="pls underline text"
Selection.Find.Execute
End If
Loop
End Sub
子下劃線() 昏暗的測量值作爲字符串 昏暗N當 測量值=的InputBox(「請輸入要搜索的文本」&VBCR&VBCR _ 和「點擊確定搜索整個工作簿的所有實例搜索文本。「) 昏暗x作爲整數 x = 0的 做,當x = 0時 隨着Selection.Find .ClearFormatting 結束隨着 如果FND =假然後 X = 1 退出執行 結束如果 Selection.Find.Execute 如果.Underline = false,那麼 Selection.Comments.Add範圍:= Selection.Range,文本:= 「請下劃線的文本」 Selection.Find.Execute 結束如果 循環 End Sub – user1553562 2012-07-31 05:46:24
這不工作..你可以給我一個替代 – user1553562 2012-07-31 05:46:44
@brettdj你可以建議我一種方法 – user1553562 2012-07-31 06:09:03