Hello :) what I want to do is to have a Master document (PowerPoint) to use as template and personalize with graphics that are in another PowerPoint presentation. The master document on the code is "pre". The PowerPoint with the graphics is "graphs_pre". The idea is to click in a image on a slide of "pre" and a input box appears asking "Please enter the name of the graph", we write the name of the graph, the code opens the "graphs_pre" search for the graph with the same name and copy and paste on the "pre". This isn't working, always giving a lot of errors. So I need your help please. Please bare in mind that I have zero experience in coding...
Code:
Sub test()
Dim vSlide As Slide
Dim vSlide As Slides
Dim vShape As Shape
Dim vShapes As Shapes
Dim pre As Presentation
Dim graphs_pre As Presentation
Set pre = ActivePresentation
Set graphs_pre = Presentations.Open ("path of the graph presentation", msoFalse)
strResult = InputBox ("Please enter the name of the graph")
Set vShapes = Presentations(Dir("path of graph presentation").Slides.Shapes
For each vShape in vShapes
If strResult = vShape.Name Then
vShape.Copy
pre.Slides.Paste
End If
Next vShape
End Sub
Let's see if this (air code) gets you a little closer:
Sub test()
Dim vSlide As Slide
'Dim vSlide As Slides
Dim vSlides as Slides
Dim vShape As Shape
Dim vShapes As Shapes
Dim pre As Presentation
Dim graphs_pre As Presentation
' You use this later w/o DIMming it so add this
Dim strResult as String
Set pre = ActivePresentation
Set graphs_pre = Presentations.Open ("path of the graph presentation", msoFalse)
strResult = InputBox ("Please enter the name of the graph")
' I don't understand what this is supposed to do
' Set vShapes = Presentations(Dir("path of graph presentation").Slides.Shapes
' but I THINK you need to do this:
For each vSlide in graphs_pre.Slides
For each vShape in vSlide.Shapes
If strResult = vShape.Name Then
vShape.Copy
' This will paste onto the first slide in pre for now
' Which slide do you really WANT it on?
pre.Slides(1)Shapes.Paste
End If
Next ' vShape
Next ' vSlide
End Sub
And once you're all done, you'll want to do graphs_pre.Close