VBA find 查找的時候 如何能都獲得查找到的個數
uj5u.com熱心網友回復:
本示例在當前演示文稿中查找所有“CompanyX”字串,并將其格式設為加粗。
For Each sld In Application.ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasTextFrame Then
Set txtRng = shp.TextFrame.TextRange
Set foundText = txtRng.Find(FindWhat:="CompanyX")
Do While Not (foundText Is Nothing)
With foundText
.Font.Bold = True
Set foundText = _
txtRng.Find(FindWhat:="CompanyX", _
After:=.Start + .Length - 1)
End With
Loop
End If
Next
Next
uj5u.com熱心網友回復:
樓上怎么會給個PPT的示例的,不過道理可能差不多
uj5u.com熱心網友回復:
word里的寫法:Sub word()
Application.ScreenUpdating = False
Dim sum&
Dim aDoc As Document: Set aDoc = ActiveDocument
With Selection
.HomeKey wdStory
Do While .Find.Execute("你好")
sum = sum + 1
Loop
End With
Application.ScreenUpdating = True
Debug.Print sum
End Sub
uj5u.com熱心網友回復:
當然使用正則可能會更快一些。。。轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/120542.html
標籤:VBA
上一篇:vb如何使button半透明
