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

相关推荐
xcbrand2 分钟前
专精特新品牌全案公司有哪些
大数据·人工智能·python
橘子编程7 分钟前
GoF 23 种设计模式完整知识总结与使用教程
java·c语言·开发语言·python·设计模式
枫叶林FYL10 分钟前
【Python高级工程与架构实战】项目五:生产级LLM Agent框架:基于PydanticAI的类型安全企业级实现
python·安全·架构
ths51210 分钟前
Python 正则表达式学习笔记(小白超详细版)(一)
python·正则表达式
飞Link15 分钟前
pprint 全量技术手册:复杂数据结构的结构化输出引擎
开发语言·前端·python
培风图南以星河揽胜20 分钟前
幻想简历!博主本人期望的 AI Agent 全栈简历:Java + Python + Vue3 跨语言实战,代码已开源!
java·人工智能·python
第一程序员20 分钟前
Python函数式编程:非科班转码者的入门指南
python·github
蓝色的杯子21 分钟前
龙虾-OpenClaw一文详细了解-手搓OpenClaw-2 Provider层
人工智能·python
AI_Claude_code31 分钟前
ZLibrary访问困境方案二:DNS-over-HTTPS/TLS配置与隐私保护实践
爬虫·python·网络协议·http·网络安全·https·网络爬虫
至此流年莫相忘35 分钟前
数据库迁移工具——Alembic
python