-3
我想在ppt的幻燈片1中將「hello」替換爲「world」。我如何使用VBA腳本來做到這一點。如何使用VBA查找和替換Powerpoint中的字符串
我想在ppt的幻燈片1中將「hello」替換爲「world」。我如何使用VBA腳本來做到這一點。如何使用VBA查找和替換Powerpoint中的字符串
Sub findAndReplaceText()
Dim sld As Slide
Set sld = ActivePresentation.Slides(1)
Dim shp As Shape
For Each shp In sld.Shapes
If shp.HasTextFrame Then
If shp.TextFrame.HasText Then
shp.TextFrame.TextRange.Text = Replace(shp.TextFrame.TextRange.Text, "hello", "world")
End If
End If
Next shp
End Sub
請注意,這不會查找/替換表格,smartart,分組形狀,圖表等中的文本。 –
我建議你讀的東西像(https://msdn.microsoft.com/en-us/library/office [在PowerPoint 2010中使用VBA入門] /v814734(v=office.14).aspx),然後嘗試自己編寫一些代碼。如果您遇到困難,請告訴我們您做了什麼,以便我們提供幫助。 –
其實,我是VBA的新手,之前我已經做過一些調查,但是我找不到所需的正確信息。你能分享一下例子嗎? –
查看此示例:http://www.skphub.com/ppt00025.htm#2 –