0

我正在使用代码通过命令按钮或宏将演示文稿属性呈现给文本框或形状。当我运行它时,我得到一个运行时错误,上面写着“ SlideShowWindows(unknown member): integer out of range. 1 is not in the valid range of 1 to 0

我应该怎么办!?提前致谢!

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
4

1 回答 1

1

SlideShowWindow只能在幻灯片放映期间访问,不能在正常/编辑模式下访问。在上面添加以下代码行Set oSl = SlideShowWindows(1).View.Slide应该会有所帮助:

ActivePresentation.SlideShowSettings.run
于 2015-05-15T18:44:45.317 回答