【发布时间】:2013-02-26 18:10:22
【问题描述】:
我的代码中出现"Object variable or With block variable not set" 错误。
这是我第一次写宏。我确实有编程知识,但这对我来说是新的。
无论如何,我想浏览演示文稿,并且对于在注释部分中包含任何文本的每个页面,我想添加一张包含该文本的新幻灯片(跟随它)。
这是我尝试过的:
Sub SlideSort()
Dim curSlide As Slide
Dim newSld As Slide
Dim curPres As Presentation
Dim curShape As Shape
Dim i As Integer
For i = 1 To ActivePresentation.Slides.Count
curSlide = ActivePresentation.Slides(i)
For Each curShape In curSlide.NotesPage.Shapes
If curShape.Type = msoPlaceholder Then
If curShape.PlaceholderFormat.Type = ppPlaceholderBody Then
If curShape.TextFrame.TextRange <> "" Then
Set newSld = ActivePresentation.Slides.Add(Index:=i + 1, Layout:=ppLayoutText)
newSld.Shapes(2).TextFrame.TextRange = curShape.TextFrame.TextRange
i = i + 1
End If
End If
End If
Next curShape
Next i
End Sub
给出错误的行是 curSlide = ActivePresentation.Slides(i)
【问题讨论】:
标签: vba powerpoint powerpoint-2010