在PowerPoint中找到slidelayout

时间:2015-06-24 11:35:17

标签: vba layout powerpoint slide

我想弄清楚我的演示文稿中是否有特定的自定义布局。 我想用它来创建一个带有TOC的幻灯片,该幻灯片列出了具有这种特定布局的幻灯片。

经过一番搜索和尝试,我得到了这一点,但它在下面的大胆项目中取消,任何建议:

Sub ShowSlideLayouts()

  Dim oSlide As Slide
  Dim idSlide As String
  Dim oLayoutName As String
  Dim sFileName As String
  Dim iFileNum As String

  sFileName = "C:\temp\PowerPointLayouts.TXT"

  iFileNum = FreeFile()
  Open sFileName For Output As iFileNum

  For Each oSlide In ActivePresentation.Slides
    idSlide = ActivePresentation.Slides.***SlideID*** <-- wrong method/member

    'Print #iFileNum, oSlide.Layout
    Print #iFileNum, ActivePresentation.Slides(idSlide).CustomLayout.Name
    'Print #iFileNum, ActivePresentation.Slides.getAttribute("layout")
    'For Each oLayoutName In ActivePresentation.Slides().CustomLayouts.Name
    'MsgBox ActivePresentation.Slides(idSlide).CustomLayout.Name
        'Print #iFileNum, oLayoutName.Id & vbTab & oLayoutName.Caption
   ' Next

 Next

  Close iFileNum

End Sub

1 个答案:

答案 0 :(得分:0)

你不需要idSlide的所有混乱; oSlide为您提供了演示文稿中每张幻灯片的参考,所以:

For Each oSlide In ActivePresentation.Slides
    Debug.Print oSlide.CustomLayout.Name
Next