|
- Sub test()
- Dim r%, i%
- Dim arr()
- Dim pptApp As PowerPoint.Application
- Dim pptPre As PowerPoint.Presentation
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- m = 0
- With ThisDocument
- For i = 1 To .Paragraphs.Count
- m = m + 1
- ReDim Preserve arr(1 To m)
- arr(m) = Replace(.Paragraphs(i).Range.Text, Chr(13), "")
- Next
- End With
-
- mypath = ThisDocument.Path & ""
- myname = "1.pptx"
- If Dir(mypath & myname) = "" Then
- MsgBox mypath & myname & "不存在!"
- Exit Sub
- End If
-
- Set pptApp = New PowerPoint.Application
- pptApp.Visible = msoTrue
- Set pptPre = pptApp.Presentations.Add
- With pptPre
- For k = .Slides.Count To 1 Step -1
- .Slides(k).Delete
- Next
- For k = 1 To UBound(arr)
- With .Slides.Add(Index:=.Slides.Count + 1, Layout:=ppLayoutTitle)
- With .Shapes("Title 1")
- With .TextFrame
- With .TextRange
- .Text = arr(k)
- With .Font
- .Name = "黑体"
- .Size = 120
- .Bold = True
- End With
- .ParagraphFormat.Alignment = ppAlignCenter
- End With
- End With
- End With
- End With
- Next
- .SaveAs FileName = ThisDocument.Path & "\结果"
- .Close
- End With
- pptApp.Quit
- Set pptPre = Nothing
- Set pptApp = Nothing
- Application.ScreenUpdating = True
- MsgBox "幻片生成完毕!"
- End Sub
复制代码 |
评分
-
2
查看全部评分
-
|