如何解决在Powerpoint中使用InputBox替换
我想使用用户输入替换所有幻灯片中的“仪器”一词。 当我将Replacement =“ ppp”设置为下面的代码时,但是当我将其更改为Replacement = InputBox时,该乐器不会被用户输入替换。
有什么建议吗?
Sub Replaceinstrument()
Dim sld As Slide
Dim shp As Shape
Dim Replacement As String
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
Replacement = InputBox("to change")
If Replacement = "" Then Exit Sub
If shp.HasTextFrame Then
If shp.TextFrame.HasText Then
With shp.TextFrame.TextRange
.Replace "instrument",Replacement
End With
End If
End If
Next shp
Next
End Sub
解决方法
因为循环中有InputBox,所以它在演示文稿中的每个形状上都在运行。这是按工作顺序排列的:
Sub Replaceinstrument()
Dim sld As Slide
Dim shp As Shape
Dim Replacement As String
Replacement = InputBox("to change")
If Replacement = "" Then Exit Sub
For Each sld In ActivePresentation.Slides
For Each shp In sld.Shapes
If shp.HasTextFrame Then
If shp.TextFrame.HasText Then
shp.TextFrame.TextRange.Replace "instrument",Replacement
End If
End If
Next shp
Next
End Sub
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。