Changing the properties of a CommandButton that have been added programmatically

T

tariq.qubti

I have used this code to create a command button programmatically in
pp, but my problem is that I can't set the caption of the button to
what I want.

And further more I want to assign an event handler to this button.
Anyone have an idea about how?! or if even this is feasible via VBA?!
Public btn As Shape

Private Sub lbSomething_Click()
Set btn = Slide2.Shapes.AddOLEObject(100, 100, 100, 100,
"Forms.CommandButton.1")
End Sub
 
S

Steve Rindsberg

I have used this code to create a command button programmatically in
pp, but my problem is that I can't set the caption of the button to
what I want.



Public btn As Shape

Private Sub lbSomething_Click()
Set btn = ActivePresentation.Slides(2).Shapes.AddOLEObject(100, 100, 100,
100, "Forms.CommandButton.1")
With btn.OLEFormat.Object
.Caption = "Any Caption You Like"
End With
End Sub

And further more I want to assign an event handler to this button.
Anyone have an idea about how?! or if even this is feasible via VBA?!

You can do this with command bar buttons but I don't know how to do it with
controls on a slide other than using the IDE's object model to write code
directly into the module.
 
Top