Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

again ...and again...Button on a slide???

Status
Not open for further replies.

maltobji

Programmer
Feb 13, 2001
31
0
0
JO
dear all,
please can any body help me....

i'm trying to insert a Button on a PowerPoint Slide at run time(while show i running)through (.AddOLEObject ...)..... the problem how the bottun will respond to the click event....(i.e how the code would be generated???)..
i tryed to add the button through a class module procedure and make it WithEvents Keyword...but unfortunatly it failed..i don't know why???????

thanx in advance
 
Couldn't you add the button, and corresponding click_event code at design time, set the visible property to false, and then reset the visible property to True at runtime when appropriate?
 
dear hackster,
Unfortunatly... the Button should be added at run-time..what u say is much simpler .... as i told u i tryed to make it inside a class with Events ... but i don't know some times it work and others not...i don't know the reason
 
hai altobji:->,
this is srusti here,i have undergone with your problem . so far me to concerned its not possible to attach an event to a control in runtime.but if you can send the code what you have written then we can try.
srusti:0)
 
What you need to do is create a class wrapper around a reference to you control that was declared WithEvents. Then you need to use the forms control collection to instantiate the control that you need to add at run time. Once the control is instantiated, set the reference in you class wrapper around the control, and you will have full access to all of the run time events that are fired.
Sorry to be brief fere, but I working right now. If you need more help with this, let me know and I will try to post an example sometime tonight. - Jeff Marler B-)
 
One more quick note . . .if you are only adding one button (and never any more), I would go with Hackster's proposed method. It will be much simpler to implement. The class wrapper idea is used when you don't know how many controls will be added at runtime. - Jeff Marler B-)
 
thanx all for your concern.....
as i sayed the problem now that it is some times work and others don't... but to be totally clear ...
What i'm really working at is my graduation project ...
it consist of some hardware keypads(wireless) ... and a central control PC.... the keypads r with the Auodience to vote about Some Case...the control Pc will collect the data.. and show the result on a graph ...

what i'm inytending to do ....
before the presentation begin... the instructor should give me the places of slides that should contain Voting(after that slide).....so i add a button to control the process during the show...


when the instructor push that button within the show ... a New Voting slide is created containing the Question and the Choices(4 till now)...and a Counter that count from 10 to 1...after that, all objects will be deleted,and the Control Pc will collect the Data....the Show them on Chart created... N.B: I WANT TO ADD SOME CONTROL BUTTONS AND RADIO BUTTONS ON THAT SLIDE(NEXT TO CHART) TO HAVE SOME CONTROL ON THE CHART....I.E CHANGE THE TYPE..CHOW RESULTS BY vALUE OR pERCENT ...CHAING THE VIEW TO 3D...ETC

THESE R THE PORBLEM I'M STUCKED WITH....

NOTE: i thinked to replace the buttons with images that act as buttons what couldn't find a replace of the radio buttons...


i now i talked too much....but i was trying to be clear as possible...(if any body wants me to send the code i will later today)

thanx all .....


 
hi all,
as promesed here is the code of the class module


Option Explicit
Public WithEvents Cmd As MSForms.CommandButton

Public Sub Create(ByVal Sld As PowerPoint.Slide)
On Error GoTo ErrHandle:
With Sld.Shapes

Set Cmd = .AddOLEObject _
(Left:=120#, _
Top:=110#, _
Width:=120, _
Height:=60, _
ClassName:="Forms.CommandButton.1", _
Link:=msoFalse).OLEFormat.Object

Set Cmd = Nothing

End With
Cmd.Caption = " START VOTE "
Cmd.TakeFocusOnClick = True
Exit Sub
ErrHandle:
'' Error handle
MsgBox "hi"
End Sub

Private Sub Class_Initialize()
'On Error GoTo ErrHandle:
'Set Cmd = GetObject("", "Forms.CommandButton.1")
Set Cmd = Nothing
' Exit Sub
'ErrHandle:
'' Error handle
End Sub

Private Sub Class_Terminate()
Set Cmd = Nothing
End Sub

Private Sub Cmd_Click()
Call CreateVoteSlide
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top