简体   繁体   中英

In powerpoint- is there such thing as object variables and if so, how do I pass that into a VBA script?

If I make a specific shape like a square and name it, for example, but then want to pass it into a script - how would I go about doing this? It seems like I can assign a VBA script to a shape when it is clicked on, but it will only run the VBA script as an independent event- how would I 'pass' in information to that VBA script- for example if the same VBA script will run differently based on a difference in the shape name...

I want to do something like this:

Sub TestA(x As String)

Shell ("explorer.exe """ + x + """")

End Sub

Where x can be an attribute- or If possible I can just name each shape the url it links to- was wondering how that could be passed into here?

Just use the shape's .Name property?

Sub TestA()
Dim x as String
x = ActivePresentation.Slides(1).Shapes("Your_Shape_Name").Name

Shell ("explorer.exe """ + x + """")

End Sub

If you assign TestClick to the shape:

Sub TestClick(oShape As Shape)
    Debug.Print oShape.Name
    'take some action depending on value of Name property...
End Sub

See: http://office.microsoft.com/en-us/powerpoint-help/change-the-action-settings-of-a-button-picture-or-clip-art-HA010256555.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM