VBA第三十九期 VBA自动把工作表转换成PPT

和前面两节一样运行Microwof PowerPoint时需要对其对象库进行引用,在Excel中打开VBE,选择"工具",激活"引用"对话框后,通过滚动条找到 Microsoft PowerPoint XX Object Library,选中该项。具体操作步骤参照前面章节。

Sub SendiMorkbookToPowerPoint ()

peclare your variables

Dim pp As PowerPoint. Application

Dim PPPres As PowerPoint. Presentation

Dim PPSlide As PowerPoint. Slide

Dim xlwksht As Excel. Worksheet

Dim MyRange As String

Dim MyTitle As String

Powerpoint,add a new presentation and make visible

Set pp= New PowerPoint. Application

Set PPPres = pp. Presentations. Add

pp. Visible= True

MyRange="A1: I00"

For Each xlwksht In ActiveWorkbook. Worksheets

xlwksht. Select

Application. Wait (Now+TimeValue("0:00:2"))

MyTitle=xlwksht. Range ("C10") . Value

xlwksht. Range (MyRange) . CopyPictureAppearance: =x1Screen, Format: =x1Picture

slideCount=PPPres. Slides. Count

Set PPSlide= PPPres. Slides. Add (S1ideCount +1, ppLayoutTitleonly)

PPSlide. Select

PPSlide. Shapes. Paste. Select

pp. ActiveWindo. Selection. ShapeRange. Align msoAlignCenters, True

pp. ActiveWindow. Selection. ShapeRange. Top=50

PPSlide. Shapes. Title. TextFrame. TextRange. Text = MyTitle

Next

'恢复初始设置,这个是不能省略的,虽然省略程序依然可以运行

pp. Activate

Set PPSlide = Nothing

Set PPPres=Nothing

Set pp=Nothing

End Sub

相关推荐
JJ1M815 分钟前
前缀和+贪心总结,基于每日一题力扣3439、3440
python·算法·leetcode
Skrrapper1 小时前
Flask 入门到实战(2):使用 SQLAlchemy 打造可持久化的数据层
后端·python·flask
云空1 小时前
《探索电脑麦克风声音采集多窗口实时可视化技术》
人工智能·python·算法
feihui1 小时前
记一次 Python 服务 TCE 实例进程异常退出排查
python·gunicorn
超龄超能程序猿2 小时前
使用 Python 对本地图片进行图像分类
开发语言·人工智能·python·机器学习·分类·数据挖掘·scipy
谢斯2 小时前
[python]在drf中使用drf_spectacular
python·django
我爱一条柴ya2 小时前
【AI大模型】RAG系统组件:向量数据库(ChromaDB)
数据库·人工智能·pytorch·python·ai·ai编程
天天爱吃肉82182 小时前
从零到一:深度解析汽车标定技术体系与实战策略
python·嵌入式硬件·自动化·汽车
还听珊瑚海吗2 小时前
Python(一)
开发语言·python
LuckyLay3 小时前
1.1.2 运算符与表达式——AI教你学Django
python·django