我正在尝试打开一个excel文件,将范围作为图片并为其创建一个ppt。我不确定下面的代码出了什么问题。有人可以帮忙吗?该代码适用于来自其他excel文件的所有其他幻灯片。当我打开excel文件并进行切换时,它会抛出“下标超出范围错误”
Sub GlobalBankPPT()
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppSlide As PowerPoint.Slide
Dim ppShape As PowerPoint.Shape
Dim ppPic As Variant
Dim j As Integer
Dim wkb As Workbook
Dim sh As Worksheet
Dim WS_Count As Integer, i As Integer
Dim mypp As New ExcelToPPt.cPPt
mypp.InitFromTemplate MyTemplateppt:=mytemp, MyOutputppt:=""
Set ppApp = GetObject(, "PowerPoint.Application")
ppApp.Visible = msoTrue
Set ppPres = ppApp.ActivePresentation
Set wkb = Workbooks.Open(Filename:=ThisWorkbook.Worksheets("Index").Range ("FilePath"))
wkb.Activate
WS_Count = wkb.Worksheets.Count
For i = 1 To WS_Count
If Worksheets(i).Name = "Industry" Then
wkb.Activate
Set sh = ActiveSheet
Exit For
End If
Next I
'--------------------------------------------------------------------Slide7
Range(Sheet15.Range("A150"), Sheet15.Range("Q191")).Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
ppPres.Slides(7).Select
Set ppPic = ppPres.Slides(7).Shapes.Paste
ppPic.Select
ppPic.Top = 70.24
ppPic.Width = 10.5 * 100
ppPic.Height = ppPic.Width / 3.4
ppPic.Left = 50
end sub