excel - 有没有办法将我的 VBA 代码中的幻灯片编号作为用户输入来操作?
问题描述
VBA新手在这里。目前正在尝试实现一些代码,将excel中的一系列单元格传输到powerpoint中给定幻灯片中表格的预先存在的行/列中。我已经使用以下代码进行了转移:
Sub ExcelRange_to_PPT_Table()
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppTbl As PowerPoint.Shape
Dim ppSlide As PowerPoint.Slide
On Error Resume Next
Set ppApp = GetObject(, "PowerPoint.Application")
On Error GoTo 0
If ppApp Is Nothing Then
Set ppApp = New PowerPoint.Application
ppApp.Visible = True
Set ppPres = PPTApp.Presentations.Add
Set ppSlide = PPTP.Slides.Add(1, ppLayoutBlank)
Else
Set ppPres = ppApp.Presentations.Item(1)
End If
ppApp.ActivePresentation.Slides(1).Select
' find on Slide Number 1 which object ID is of Table type (you can change to whatever slide number you have your table)
With ppApp.ActivePresentation.Slides(1).Shapes
For i = 1 To .Count
If .Item(i).HasTable Then
ShapeNum = i
End If
Next
End With
' assign Slide Table object
Set ppTbl = ppApp.ActivePresentation.Slides(1).Shapes(ShapeNum)
' copy range from Excel sheet
Range("A1:D5").Copy
' select the Table cell you want to copy to >> modify according to the cell you want to use as the first Cell
ppTbl.Table.Cell(1, 1).Shape.Select
' paste into existing PowerPoint table - use this line if you want to use the PowerPoint table format
ppApp.CommandBars.ExecuteMso ("PasteExcelTableDestinationTableStyle")
End Sub
我想实现某种用户 IO,允许用户在 excel 中输入他们想要传输的范围以及他们想要传输到的表格的幻灯片 # + 行/列,但是我正在努力使用将更改预设的 VBA 代码来执行此操作的用户 io。有什么建议么?谢谢!
解决方案
推荐阅读
- angularjs - 为什么 element.$error.email 为 null 而不是 false?
- azure - 为什么持久功能需要太多时间才能“完成”?
- express - 服务器没有运行
- r - R tidyverse 工作流程中的逐步模型选择
- python - float64 在 netcdf4 中写入 nan
- php - 如何在 jQuery 包含之后放置 jQuery 代码?
- c# - 反序列化 DateTime 格式不适用于周二缩写
- machine-learning - 为什么每个时代之后损失突然下降?
- authentication - IdentityServer4 用户范围/权利/声明?
- css - :not(:has(td[rowspan])) 的 CSS 选择器?