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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WithEvents and powerpoint Slide????

Status
Not open for further replies.

maltobji

Programmer
Feb 13, 2001
31
0
0
JO
dear all,
i may bothered some people but i'm working in my graduation project...so please if any body knows ..please help


Why WithEvents (in class module) doesn't work properly inside Powerpoint....

i tryed to add a button into a slide (at run-time)....but unfortunatly it did not respond to the click event...

some told me to make class wrapper..which i don't know what it is...
any help.

thanx in advance

 
altobji,
I mentioned the class wrapper. To use it, you need to create a class module and inside of the class module, delcare a pointer to the control you will be working with and declare it with events, but not new. For example . . .

Code:
Private WithEvents objTextBox as TextBox


Now, I am not sure if you can do this diretly inside of PowerPoint, so what you may need to do is to create an ActiveX DLL with the class wrappers in VB and reference that library from within PowerPoint. Eitherway, you will need to set the classwrappers control reference when you dynamically create the object and the code to respond to the events will need to be preprogrammed into the class wrapper code.

- Jeff Marler B-)
 
thanx jmarler for ur time,...
i may misunderstand....

but i already declared (inside a class module in powerpoint)..the button to be added with the WithEvents Statement..i.e
Public WithEvnets CmdVote as CommandButton

but it also did not respond...

thanx again

 
Great . . . you've declared the variable with events! That is the first step . . . have you remembered to set the varaible reference inside of the class when you created the varaible? For example . . .

Code:
dim objClassWrapper as MyClassWrapper
set objClassWrapper = new MyClassWrapper

set objClassWrapper.CmdVote = forms1.controls.add("CommandButton","cmdVote")


The above code may not be exactly correct, but the basic idea is that you need to set the control reference insdie of the control wrapper to the control that you dynmically created on the form.
- Jeff Marler B-)
 
dear jmarler ,

i remembered ... but unfortunatly also failed...
the button on a slide is added as an ActiveX control(Added as an OLE object)...
so i don't know why it does not respond to the events
.. any way i tryed to create a macro to add a button on the currect slide (as a test of my work)....

here is the code of the Macro
__________________________________________________________
Option Explicit
Public Cmd As New AddingButton

Sub addButton()
On Error GoTo ErrHandle:


With ActiveWindow.Selection.SlideRange.Shapes
Set Cmd.Control = .AddOLEObject _
(Left:=120#, _
Top:=110#, _
Width:=120#, _
Height:=60#, _
ClassName:="Forms.CommandButton.1", _
Link:=msoFalse).OLEFormat.Object
End With

Exit Sub
ErrHandle:
MsgBox "Error in AddButton"
End Sub
___________________________________________________________


and the code of the Class Module (called AddVoteButton)..
(Final Version..;)
______________________________________________

Option Explicit
Private WithEvents Cmd As MSForms.CommandButton

Private Sub Class_Initialize()
'' tryed this but failed (Cmd here always returned with create object false)
'' Set Cmd = CreateObject("Forms.CommandButton.1")
End Sub

Public Property Set Control _
(ByVal CmdControl As CommandButton)
Set Cmd = CmdControl
Cmd.Caption = " START VOTE "
Cmd.TakeFocusOnClick = True
End Property
_________________________________________________________
Private Sub Cmd_Click()
'Call CreateVoteSlide ''the method that should be called MsgBox "Correct" '' for test
End Sub


all this did not work....

oh... i found something you might be gone through such...

when i run the macro ... the first give button that doesn't work..
But when i run the macro twice...(following each other)
i give a button that works!!!!!!!!!!!!!!!!!!!

thanx again for ur time

and the
 
===============================================================================

Taking a look at your Property Set function in your class wrapper . . .

Code:
"Public Property Set Control (ByVal CmdControl As CommandButton)"


I noticed that you are trying to pass the control reference in ByVal. This will not work. You need the pointer to the original control, so you should be passing the control reference into the function. Since it is all in the same process space, you should not incur any real performance hit. Try it again, but pass the control in ByRef.
- Jeff Marler B-)
 
sorry for taking ur time...
but i tryed what u said but with no success ...

as i told u ... there something weared ...
i made some watch for the (Cmd as AddingButton)..
if i run the macro once ... the type partion of the watch keep Empty.. and so the button doesn't work

but when i run the macro twice .... the type appear to be (AddingButton )...and the resulting button works .!!!!!!!
why is that i have no clue....

thanx alot for ur time and concern.....
 
hmmm . . . the class wrapper method should work fine unless of course PowerPoint is doing something odd with the objects. I have used class wrappers several times before, but never within PowerPoint. If I get a moment, I'll look at PowerPoint and see if I can make sense of it. - Jeff Marler B-)
 
thanx alot jmarler ,.

i'm sorry that i put u through all this..taking alot from ur time
..thanks alot....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top