excel - 如何从 Excel 工作簿更新 powerpoint 表
问题描述
我正在尝试编写一个从 excel 运行的代码,然后从 c 盘打开一个现有的 excel 和 powerpoint 文件,并使用名为“Oct18”的工作表中的数据更新幻灯片 2 中的 FIRST 表。
以下是我编写的代码,但不知何故它不起作用。我可以知道是否有人知道该怎么做吗?
Sub WriteText_toPPT_Table()
'Add a reference to Microsoft Powerpoint 12.0 object library
Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppShp As PowerPoint.Shape
Dim ppSld As PowerPoint.slide
Dim xlworkbook As Workbook
Dim firstsheet As String
Dim fileDir As String
Dim excelFile As String
firstsheet = "Oct18"
'fileDir = "c:\masterpresentation.pptx"
'excelFile = "c:\masterexcel.pptx
'1) Open powerpoint application
Set ppApp = CreateObject("PowerPoint.Application")
ppApp.Visible = msoTrue
Set xlworkbook = Excel.Application.Workbooks.Open(Filename:=excelFile)
'2) opening an existing presentation
Set ppPres = ppApp.Presentations.Open(Filename:=fileDir)
Set exceldir = Excel.Application.Workbooks.Open(Filename:=excelFile)
ppPres.Slides(2).Shapes(1).Table.Cell(1, 1).Shape.TextFrame.TextRange.Text = xlworkbook.Sheets(firstsheet).Cells(4, 12)
End Sub
解决方案
推荐阅读
- android - Android 打印自定义布局
- visual-studio-2013 - 适用于 Windows 7 的 Crystal 报表查看器
- python-3.x - python asyncio 在这种情况下,我是否必须在所有代码中都写“await”?有没有更有效的方法?
- python - Python - 从导入的模块注册函数
- python - Pandas:如何对基于两列的过滤行进行数学计算?
- azure - 使用托管标识将 Azure SQL 数据库链接到数据工厂
- java - Spring Kafka Consumer - 从复杂对象中获取主题
- python - getPerspectiveTransform 和 warpPerspective 如何工作?[Python]
- c# - 如何从 Web Api 包中导入类
- java - 是否可以在 firestore 中获取文档作为自定义对象以在 android 活动中使用它?