0

I am using a code to present the presentation properties to a textbox or shape via a command button or Macro. When I run it I get a run time error that say " SlideShowWindows(unknown member): integer out of range. 1 is not in the valid range of 1 to 0

What should I do!? Thanks in advance!

Sub ReportStuff()
    Dim oSl As Slide
    Dim oSh As Shape

    Set oSl = SlideShowWindows(1).View.Slide

    ' Test to see if the shape's already there:
    Set oSh = IsItThere(oSl, "My Text Box")

    ' If it's not there, add it:
    If oSh Is Nothing Then
       Set oSh = oSl.Shapes.AddTextbox(msoTextOrientationHorizontal, 100, 100, 200, 50)
       oSh.Name = "My Text Box"
    End If

    With oSh.TextFrame.TextRange
        .Text = "Index: " & oSl.SlideIndex & " ID: " & oSl.SlideID & " File: " & ActivePresentation.FullName
    End With

End Sub

Function IsItThere(oSl As Slide, sName As String) As Shape
   Dim oSh As Shape
   For Each oSh In oSl.Shapes
      If oSh.Name = sName Then
         Set IsItThere = oSh
         Exit Function
      End If
   Next
End Function
dHumphrey
  • 307
  • 2
  • 7
  • 24

1 Answers1

1

SlideShowWindow is only accessible during a slideshow, not in normal/ edit mode. Adding the following line of code above Set oSl = SlideShowWindows(1).View.Slide should help:

ActivePresentation.SlideShowSettings.run
StoriKnow
  • 5,738
  • 6
  • 37
  • 46
  • You've already got a thread on this same subject going; please don't start additional threads. – Steve Rindsberg May 16 '15 at 03:17
  • 1
    What are you talking about? – StoriKnow May 16 '15 at 04:12
  • Perhaps it's not your thread, but you've copied the code from here, no? http://stackoverflow.com/questions/30261814/add-powerpoint-slide-to-textbox-with-commandbutton-vba Keeping the responses to it there would only make sense. – Steve Rindsberg May 16 '15 at 15:52
  • 2
    If you have an issue with the question itself then your comments would be more appropriately placed in the `question` section, not in this answer. It does look like the OP (not me, I'm just providing answers) copied the code from there; I'm failing to understand why you're not directing your energy toward him/ her. – StoriKnow May 16 '15 at 16:12
  • 1
    @SteveRindsberg, you should put these comments in the comment section of the OP, not an answer. If you feel it is a duplicate, you can flag it as such on the OP. – Todd Main May 17 '15 at 18:28