• Ask a Question
150
Insert Image Size must be less than < 5MB.
    Ask a Question
    Cancel
    150
    More answer You can create 5 answer(s).
      Ask a Poll
      Cancel
      Top Contributor

      How to find slide number in PowerPoint Presentation ?

      I want to find slide number in PowerPoint Presentation using VBA.

      Asked by Lora on September 6, 2017 in VBA PowerPoint.
      4 Answers
      Expert

      Hello Lora

      Try this code

      Sub Test()
      MsgBox ActivePresentation.Slides.Count
      End Sub
      
      Answered by YasserKhalil on September 6, 2017..
      Top Contributor

      HI Yasser,

      Thanks for your code. But, code represents total number of slides in a presentation.

      I want to get into each slide in a presentation. I want to refer each and every slide in a presentation to update images in each slide using VBA.

      Answered by Lora on September 7, 2017..
      Expert

      It is not totally clear for me ..

      Answered by YasserKhalil on September 7, 2017..
      Keymaster

      Hello Lora,

      Please check below procedures, I hope one of this will help to solve your query.

      You can get the Active Slide Number using the below procedure

      Sub sbGetActiveSlideNumber()
      actSldNo = ActiveWindow.Selection.SlideRange.SlideNumber
      MsgBox actSldNo
      End Sub
      

       

      You can set the ActiveSlide to an object and do whatever you wants to.

      Sub sbSetActiveSlideNumber()
      Set actSld = ActiveWindow.Selection.SlideRange
      'to Get the slide number
      MsgBox actSld.SlideNumber
      ' Loop through all shapes in the slide
      For Each shp In actSld.Shapes
      MsgBox shp.Name
      Next
      End Sub
      

       

      Set a Specific Slide to an object and do whatever you wants to.

      Sub sbSetSpecificSlideNumber()
      Set actSld = ActivePresentation.Slides(5)
      ' Loop through all shapes in the slide
      For Each shp In actSld.Shapes
      MsgBox shp.Name
      Next
      End Sub
      

       

       

      Loop through all slides and perform some thing in each slide.

       

      Sub sbLoopAllSlides()
      'Loop through all slides
      For Each sld In ActivePresentation.Slides
      'Perform something in each slide
      For Each shp In sld.Shapes
      MsgBox shp.Name
      Next shp
      'Or do something for a specific slide
      If sld.SlideNumber = 2 Then
      'your statements
      End If
      Next sld
      End Sub
      

      Thanks!

       

      Answered by PNRao on September 8, 2017..