|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub ExportToPPT()
Dim ppt As Object
Dim slide As Object
Dim shape As Object
Dim title As String
Dim i As Long
Dim j As Long
' 获取需要导出的标题
title = InputBox("请输入需要导出的标题", "导出 PPT")
' 如果没有输入标题,退出程序
If Len(title) = 0 Then Exit Sub
' 新建 PPT 文件
Set ppt = CreateObject("PowerPoint.Application")
ppt.Visible = True
ppt.Presentations.Add
' 遍历 Excel 表格中的每个单元格,查找标题
For i = 1 To ActiveSheet.Cells.SpecialCells(xlLastCell).Row
For j = 1 To ActiveSheet.Cells.SpecialCells(xlLastCell).Column
If ActiveSheet.Cells(i, j).Value = title Then
' 新建 PPT 页面,并将标题复制到页面中
Set slide = ppt.ActivePresentation.Slides.Add(ppt.ActivePresentation.Slides.Count + 1, 11)
Set shape = slide.Shapes.AddTextEffect(msoTextEffect1, title, "Arial", 36)
shape.Top = 50
shape.Left = 50
Exit For
End If
Next j
Next i
' 关闭 PPT 文件
Set slide = Nothing
Set ppt = Nothing
End Sub
|
|