我在我的代码中出现"Object variable or With block variable not set"
错误。 这是我在宏观写作方面的第一个破解。我有编程知识,但这对我来说是新的。vba:powerpoint宏:“变量未设置”
无论如何,我想要通过演示文稿,并且对于每个在备注部分有任何文本的页面,我都想添加一个包含该文本的新幻灯片(在其后面)。
这里是我的尝试:
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)
谢谢!出于好奇,有什么更明智的方式去做我想做的事情? 我猜想宏这样的计算效率并不是特别的本质。 – JoshDG 2013-02-26 19:56:34
也许结合使用'和'的嵌套'If's。 – 2013-02-26 19:58:29
此外,修正set命令后,我得到了一个新的错误:PlaceholderFormat(未知成员):失败 对于此行:如果curShape.PlaceholderFormat.Type = ppPlaceholderBody然后 – JoshDG 2013-02-26 20:01:05