Weird bug on powerpoint vba

佐手、 提交于 2019-12-11 13:35:57

问题


I have a "mynote" textbox on a slide. If I execute:

Sub test()

            If ActiveWindow.Selection.SlideRange.Shapes("mynote").Visible Then
                MsgBox "ok"
            End If
end sub

It works.

But If I attach a shape with this macro:

Sub test(oShape As Shape)

            If ActiveWindow.Selection.SlideRange.Shapes("mynote").Visible Then
                MsgBox "ok"
            End If
end sub

It doesn't work (no error message, no "ok" message)


回答1:


It will depend on how you call it from another sub routine - you have to send in a shape. Like:

Sub testYourTest()
    Dim sh As Shape
    Set sh = ActivePresentation.Slides(4).Shapes(1)
    test sh
End Sub

You can't run test stand-alone because it is expecting you to send in a Shape object. But seeing as your oShape object is not being used in your test routine, you may as well remove it.



来源:https://stackoverflow.com/questions/2980650/weird-bug-on-powerpoint-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!