vba - 从 2016 到更低版本的 vba 兼容性
问题描述
我编写了以下代码,用于将 Excel 工作表中的数据复制并粘贴到 Microsoft Excel 2016 版本的 Powerpoint 幻灯片中。
但是,当我在较低的 Microsoft Excel 版本上运行此代码时,它会在提到的位置(代码的倒数第二行)给出错误消息:-
Sub excltoppt()
Dim ppalApp As PowerPoint.Application
Dim ppalPres As PowerPoint.Presentation
Dim ppalSlide As PowerPoint.Slide
Set ppalApp = New PowerPoint.Application
ppalApp.Visible = True
ppalApp.Activate
Set ppalPres = ppalApp.Presentations.Open("C:\Desktop\Template.pptx")
ppalPres.Slides(6).Duplicate
Set ppalSlide = ppalPres.Slides(6)
'here it select data from specific excel sheet #6
Sheets("S06").Select
ActiveSheet.Range("D1:G21").Select
ActiveSheet.Shapes.SelectAll
Selection.Copy
'here it paste at the selected specific slide #6
ppalSlide.Shapes.PasteSpecial DataType:=wdPasteText
'here it select data from specific excel sheet #6
Sheets("S06").Select
ActiveSheet.Range("D14:H18").Select
Selection.Copy
'here it paste at the selected specific slide #6 - AND AT THIS PLACE I AM GETTING ERROR MESSAGE
ppalSlide.Shapes.PasteSpecial DataType:=wdPasteText
End Sub
它从excel复制数据,将其粘贴到ppt,再次从excel复制,但这次它没有将其粘贴到ppt。
解决方案
推荐阅读
- php - PHP 从 UDP 套接字连续读取
- javascript - 如何在 html 文件中使用 Node.js Express 函数
- java - Java 正则表达式强制搜索大小写
- c++ - rethrow_if_nested 可能的实现
- node.js - 如何提高 nodejs 代码中的内存使用率?
- multithreading - 证明算法是无死锁的
- python - 画框字符界面的问题
- azure - New-AzADAppCredential 生成客户端密钥
- sql - 在多个国家/地区可用的 SQL SELECT 产品
- azure - 如何将服务公开给 Kubernetes 中的其他 pod?