excel - 在 VBA 中从两个不同的 excel 文件创建 PPT
问题描述
我正在尝试打开一个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
解决方案
推荐阅读
- apache-flink - 如何减少 Flink intra-jobs 之间的时间并避免重复任务
- excel - Excel为一个单元格内的两个值添加相同的前缀
- download - 用于 linux 的 Netezza odbc 驱动程序下载失败
- javascript - 通过 PWA 的社交媒体分享图片
- web-scraping - 如何在不使用 Twitter API 的情况下获取只有推文 ID 的推文?
- xml - Azure APIM 中的 XML 转换
- r - R for loop wise : Rowwise sum on conditions : 性能问题
- r - 如何在 R markdown 中增加数据表的高度
- c# - 如何在类库中处理数据时将数据从类库发送回 Web 表单应用程序?
- r - 如何将绘图更改为 ggplot 格式?