Log in

View Full Version : Execute VBA Code in some slides of presentation



Wox17
05-04-2015, 06:43 AM
Hello experts!

Im using powerpoint 2010.

I need to run a macro that I have programmed only in some slides. For example I have 20 slides and I would like to run macro when select slides with CTRL button in left pane.

How can I achieve this?

Thanks!

John Wilson
05-10-2015, 04:38 AM
Like this:


Sub selectedSlidesOnly()
Dim osldRng As SlideRange
Dim osld As Slide
On Error Resume Next
Set osldRng = ActiveWindow.Selection.SlideRange
If Not osldRng Is Nothing Then
For Each osld In osldRng
'Do whatever
'example only
osld.Shapes.AddCallout msoCalloutThree, 10, 10, 100, 100
Next osld
End If
End Sub