Vba 在Powerpoint中使用InputBox替换
我想用用户的输入替换所有幻灯片中的“仪器”一词。 当我设置Replacement=“ppp”时,下面的代码起作用,但当我将其更改为Replacement=InputBox时,仪器没有被用户输入替换 有什么建议吗Vba 在Powerpoint中使用InputBox替换,vba,powerpoint,inputbox,Vba,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.Sli
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
我错过了这么简单的一件事。谢谢