spillthebean
03-14-2014, 07:48 AM
Dear forum,
I am very very new to VBA and have just spent all day creating the macro I need. . . and then accidentally told powerpoint to close the wrong window, and I lost all my code. Lesson learned.
I was wondering if anyone would be willing to help me recreate my work, as I keep getting everything wrong. What I had was something that would:
Dim Template As Presentation
Dim Target As Presentation
Set Template = Presentations.Open("S:\Documents\Documents\Syllable\Syllable template.pptx")
Set Target = Presentations.Open("S:\Documents\Documents\Syllable\blank.pptx")
Dim s As Integer
s = 20
Template.Windows(1).Activate
ActivePresentation.Slides(s).Copy
Target.Windows(1).Activate
ActivePresentation.Slides.Paste
So it would take whatever Template slide number I said and paste it at the end of the Target presentation.
That's it, only I had that 34 different times, because I need all 34 slides, but in a specified new order. And then I changed the number S was in between each time I told it to copy and paste S.
Clearly there has to be an easier way to do this. If I have to recreate my work, I might as well try to make it better the second time! Is there a way you can create the copy and pasting business as a function, then say for each value of s, run the function?
If anyone could help, I would greatly appreciate learning.
I am very very new to VBA and have just spent all day creating the macro I need. . . and then accidentally told powerpoint to close the wrong window, and I lost all my code. Lesson learned.
I was wondering if anyone would be willing to help me recreate my work, as I keep getting everything wrong. What I had was something that would:
Dim Template As Presentation
Dim Target As Presentation
Set Template = Presentations.Open("S:\Documents\Documents\Syllable\Syllable template.pptx")
Set Target = Presentations.Open("S:\Documents\Documents\Syllable\blank.pptx")
Dim s As Integer
s = 20
Template.Windows(1).Activate
ActivePresentation.Slides(s).Copy
Target.Windows(1).Activate
ActivePresentation.Slides.Paste
So it would take whatever Template slide number I said and paste it at the end of the Target presentation.
That's it, only I had that 34 different times, because I need all 34 slides, but in a specified new order. And then I changed the number S was in between each time I told it to copy and paste S.
Clearly there has to be an easier way to do this. If I have to recreate my work, I might as well try to make it better the second time! Is there a way you can create the copy and pasting business as a function, then say for each value of s, run the function?
If anyone could help, I would greatly appreciate learning.