和前面两节一样运行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

Logo

中国智能体开发者社区,聚焦智能体与大模型开发,提供前沿资讯、实用工具链、开源项目及行业案例。通过技术沙龙、开发者大赛等活动,促进经验交流与协作,助力开发者快速构建创新智能应用。

更多推荐