PowerPoint VBA创建和保存幻灯片

InDesigner

当我分别调用每个模块时,一切正常...但是当我从MAIN模块中调用它们时,文本不会在保存的幻灯片溢出时缩小。您能帮忙找到解决此问题的方法吗

Sub MAIN()

Call Module1.CreateSlides
Call Module2.SaveSlides

End Sub

   

[ Module1 ]

Sub CreateSlides()

'Open the Excel workbook. Change the filename here.
Dim OWB As New Excel.Workbook
Set OWB = Excel.Application.Workbooks.Open("C:\B\Books\TXT.xlsx")

'Grab the first Worksheet in the Workbook
Dim WS As Excel.Worksheet
Set WS = OWB.Worksheets(1)

'Loop through each used row in Column A
For i = 1 To WS.Range("A65536").End(xlUp).Row

    'Copy the first slide and paste at the end of the presentation
    ActivePresentation.Slides(1).Copy
    ActivePresentation.Slides.Paste (ActivePresentation.Slides.Count + 1)

    'Change the text of the first text box on the slide.
    ActivePresentation.Slides(ActivePresentation.Slides.Count).Shapes(1).TextFrame.TextRange.Text = WS.Cells(i, 1).Value
    ActivePresentation.Slides(ActivePresentation.Slides.Count).Shapes(2).TextFrame.TextRange.Text = WS.Cells(i, 2).Value
    ActivePresentation.Slides(ActivePresentation.Slides.Count).Shapes(3).TextFrame.TextRange.Text = WS.Cells(i, 3).Value
 Next

'Close Excel
ActiveWorkbook.Close

'Delete presentation
ActivePresentation.Slides(1).Delete

End Sub

[ Module2 ]

Sub SaveSlides ()

'Save slides as png
Dim sImagePath As String
Dim sImageName As String
Dim oSlide As Slide '* Slide Object

On Error GoTo Err_ImageSave

sImagePath = "C:\"
For Each oSlide In ActivePresentation.Slides
    sImageName = oSlide.SlideNumber & ".png"
    oSlide.Export sImagePath & sImageName, "PNG"
Next oSlide

Err_ImageSave:
If Err <> 0 Then
    MsgBox Err.Description
End If

'Delete all slides
Dim Pre As Presentation
Set Pre = ActivePresentation
Dim x As Long
For x = Pre.Slides.Count To 1 Step -1
    Pre.Slides(x).Delete
Next x

'Add New slide
Set pptLayout = ActivePresentation.Designs(1).SlideMaster.CustomLayouts(1)
Set Sld = ActivePresentation.Slides.AddSlide(1, pptLayout)
Sld.Design = ActivePresentation.Designs(1)

End Sub
InDesigner

修复模块要单独应用

Sub FixUp()

Dim Obj1 As Object
Set Obj1 = CreateObject("powerpoint.application")
Obj1.Presentations.Open FileName:="C:\B\name.pptm"

    Dim pptSlide As Slide
    Dim pptShape as Shape
    'Set pptSlide = ActivePresentation.Slides(1)
    For Each pptSlide in ActivePresentation.Slides
      'With pptSlide.Shapes(1)
       For Each pptShape in pptSlide.Shapes
          With pptShape
          If .TextFrame2.TextRange.Characters.Count > 1 Then
              .TextFrame2.AutoSize = msoAutoSizeTextToFitShape
          End If
          End With '  pptShape
       Next  ' pptShape
      End With
    Next   ' Slide
End Sub

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

VBA PowerPoint幻灯片标题

来自分类Dev

从Access VBA填充Powerpoint幻灯片

来自分类Dev

PowerPoint VBA选择幻灯片

来自分类Dev

PowerPoint幻灯片计数

来自分类Dev

使用VBA在excel中的每张幻灯片上创建带有多个图表的Powerpoint

来自分类Dev

VBA Powerpoint按名称选择幻灯片

来自分类Dev

PowerPoint VBA导出某些幻灯片到pdf

来自分类Dev

PowerPoint VBA宏可跳过幻灯片上的动画

来自分类Dev

从Access VBA打开PowerPoint演示文稿的特定幻灯片

来自分类Dev

Excel VBA在PowerPoint中复制幻灯片

来自分类Dev

PowerPoint VBA导出某些幻灯片到pdf

来自分类Dev

如何使用VBA动态引用PowerPoint幻灯片

来自分类Dev

VBA 中的 Powerpoint 幻灯片计数变量

来自分类Dev

VBA 不循环任何 PowerPoint 幻灯片

来自分类Dev

什么是从 JSP 创建 powerpoint 幻灯片的 Java 库

来自分类Dev

检测PowerPoint幻灯片是否被隐藏

来自分类Dev

PowerPoint:打印幻灯片-扩大尺寸

来自分类Dev

如何添加PowerPoint幻灯片标题?

来自分类Dev

PowerPoint:记住“隐藏幻灯片”模式

来自分类Dev

PowerPoint VBA代码将焦点重新带到正在运行的PowerPoint幻灯片放映中

来自分类Dev

Powerpoint幻灯片显示不在幻灯片中的页面

来自分类Dev

使用母版在VBA中为PowerPoint 2010创建具有自定义布局的新幻灯片

来自分类Dev

Powerpoint 2013的幻灯片是否比Powerpoint 2010的幻灯片宽?

来自分类Dev

将图列表保存到最新R版本3.6中的Powerpoint幻灯片

来自分类Dev

使用VBA更改Powerpoint 2013中幻灯片元素的颜色

来自分类Dev

使用vba在PowerPoint 2007中的幻灯片上定位图像

来自分类Dev

在VBA powerpoint中如何将新幻灯片添加到空白演示文稿

来自分类Dev

如何通过Access VBA在Powerpoint中添加幻灯片,仅使其最小化

来自分类Dev

使用vba在PowerPoint 2007中的幻灯片上定位图像

Related 相关文章

  1. 1

    VBA PowerPoint幻灯片标题

  2. 2

    从Access VBA填充Powerpoint幻灯片

  3. 3

    PowerPoint VBA选择幻灯片

  4. 4

    PowerPoint幻灯片计数

  5. 5

    使用VBA在excel中的每张幻灯片上创建带有多个图表的Powerpoint

  6. 6

    VBA Powerpoint按名称选择幻灯片

  7. 7

    PowerPoint VBA导出某些幻灯片到pdf

  8. 8

    PowerPoint VBA宏可跳过幻灯片上的动画

  9. 9

    从Access VBA打开PowerPoint演示文稿的特定幻灯片

  10. 10

    Excel VBA在PowerPoint中复制幻灯片

  11. 11

    PowerPoint VBA导出某些幻灯片到pdf

  12. 12

    如何使用VBA动态引用PowerPoint幻灯片

  13. 13

    VBA 中的 Powerpoint 幻灯片计数变量

  14. 14

    VBA 不循环任何 PowerPoint 幻灯片

  15. 15

    什么是从 JSP 创建 powerpoint 幻灯片的 Java 库

  16. 16

    检测PowerPoint幻灯片是否被隐藏

  17. 17

    PowerPoint:打印幻灯片-扩大尺寸

  18. 18

    如何添加PowerPoint幻灯片标题?

  19. 19

    PowerPoint:记住“隐藏幻灯片”模式

  20. 20

    PowerPoint VBA代码将焦点重新带到正在运行的PowerPoint幻灯片放映中

  21. 21

    Powerpoint幻灯片显示不在幻灯片中的页面

  22. 22

    使用母版在VBA中为PowerPoint 2010创建具有自定义布局的新幻灯片

  23. 23

    Powerpoint 2013的幻灯片是否比Powerpoint 2010的幻灯片宽?

  24. 24

    将图列表保存到最新R版本3.6中的Powerpoint幻灯片

  25. 25

    使用VBA更改Powerpoint 2013中幻灯片元素的颜色

  26. 26

    使用vba在PowerPoint 2007中的幻灯片上定位图像

  27. 27

    在VBA powerpoint中如何将新幻灯片添加到空白演示文稿

  28. 28

    如何通过Access VBA在Powerpoint中添加幻灯片,仅使其最小化

  29. 29

    使用vba在PowerPoint 2007中的幻灯片上定位图像

热门标签

归档