Command button in Powerpoint

  • Thread starter Thread starter Jerry Anderson
  • Start date Start date
J

Jerry Anderson

I have a command button on a Powerpoint slide titled "cmdExit". I have turned
off the "right click" menu, and want the application to quit when I click on
the button. I have entered the following code:

Private Sub cmdExit_Click()

With Application.Presentations("Technology Team.ppt")
.Saved = True
.Close
End With

End Sub

When I click the button, it does't do anything. What am I doing wrong?
 
Chirag-
Thanks for responding. I did as you suggested, but still no response. When I
click on the button, it makes a slight move, but nothing else.
Most of the work I do with VBA is in Access; there, you must set the "Event"
property of the control in order for it to see that there is an attached
module. I don't see such a property on the Powerpoint control. Am I missing
something here?
 
Jerry Anderson said:
Private Sub cmdExit_Click()

With Application.Presentations("Technology Team.ppt")
.Saved = True
.Close
End With

End Sub

1) If the presentation "Technology Team.ppt" isn't open, it won't do anything,
of course (other than maybe throw an error)

2) The button is named cmdExit ? If not, it won't invoke the code.

3) Your macro settings allow macros to run?

Put a breakpoint at the "With ..." line, put the presentation in Show view and
click the button. Does the code stop at the breakpoint?

And btw, you don't have to use command buttons ... you can assign a Run Macro
setting (set it to your macro name) to any shape you can click.
 
In PowerPoint, all macros associated with shapes on slides in a presentation
get executed only during slide show. You seem to be trying to click the
button in the slide design view. The button click event handler won't get
executed in the design view. You need to start the slide show (press F5) and
then click on that button.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
 
Back
Top