Reputation: 279
i wanna add to a List(Collection) several slides. My code is like that:
Set inhaltsverzeichnis_Slides = New Collection
Dim inhaltsverzeichnis_Slide As slide
intNrSlide = CInt(titels.Count / 4)
slide = 1
For i = 1 To intNrSlide
slide = slide + 1
Set inhaltsverzeichnis_Slide = Application.ActivePresentation.Slides.Add(slide, ppLayoutText)
inhaltsverzeichnis_Slides.Add (inhaltsverzeichnis_Slide)
Next i
But i get a runntimeError 438. Why can not i add a slide to a collection?? And How can i do that?
Thx
Upvotes: 0
Views: 87
Reputation: 5385
You need to change the line where you add the slide object to the collection to the following (without the parentheses):
inhaltsverzeichnis_Slides.Add inhaltsverzeichnis_Slide
You cannot use parentheses without a return value - if you really want to use them for some reason, you need to use the Call
statement:
Call inhaltsverzeichnis_Slides.Add(inhaltsverzeichnis_Slide)
Upvotes: 0
Reputation: 1922
Here is an example that adds all slides of the current presentation to a collection:
Dim tmpSlide as Slide
Dim colSlides as New Collection
For Each tmpSlide In Application.Presentations(1).Slides
colSlides.Add tmpSlide
Next tmpSlide
Upvotes: 1