Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 在Powerpoint中使用InputBox替换_Vba_Powerpoint_Inputbox - Fatal编程技术网

Vba 在Powerpoint中使用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

我想用用户的输入替换所有幻灯片中的“仪器”一词。 当我设置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

我错过了这么简单的一件事。谢谢