PDA

View Full Version : Combining slides that have VBA Code (PP2010)



jlingle
02-19-2012, 08:28 AM
I have a number of "template" slides, each of which has a VBA module instructing it how to update it's shapes, charts, etc. base on an Excel spreadsheet it can open and read. I want to combine these template slides into a single deck. I used the "NewSlide:reuse" command to insert the first slide behind the second. That worked great. Both slides were in the deck with their VBA modules intact. I then tried to do the same thing with another slide, expected its VBA code to come along with it. The slide was appended to the other two. However, the third slide's VBA module replaced the VBA module of the second slide. The second slide's module disappeared. Even worse, when I save the file with the three slides and then reopened it, only the VBA code from the first slide re-appears (although the other two slides--without their VBA code--were still part of the file. Is there any way to append a series of slides to one another so their VBA code comes along with them? Thanks.

John Wilson
02-19-2012, 08:47 AM
Slides : Reuse does NOT import a module from the VBe. You would need to export the module from each presentation and then import to the new one. Make sure the modules have different names and in the VBE Project Explorer RIGHT Click > Export (or Import)

jlingle
02-19-2012, 11:57 AM
Great. Thanks once again John. I also figured out the line of code I can put into my "control slide" to import the models I will need:

ActivePresentation.VBProject.VBComponents.Import("path + filename')

It's nice having a program that can modify itself :-) Now, if I can just use an array to hold the Module names I need to call. If not, I suppose I can set up a look-up table with the "Select Case" structure to call the ones I need. Thanks again.

jlingle
02-19-2012, 03:00 PM
So, to continue this conversation:

I can write a line of VBA code to either "import" or "Export" a VBA module from a file (see previous post). But, for the life of me, I can't seem to construct a VBA statement that will "remove" a VBA module. Is there a way to do that? :banghead:

John Wilson
02-19-2012, 03:56 PM
Sub modkill()
Dim vbcomp As Object
Set vbcomp = ActivePresentation.VBProject.VBComponents
vbcomp.Remove VBComponent:= _
vbcomp.Item("Module1")
End Sub

jlingle
02-19-2012, 05:14 PM
Thanks yet again. I got all the way up to "remove" but then didn't know what "VBComponent as VBComponent" was trying to tell me that I needed the ":=" followed by the component with the complete objective definition (e.g., ActivePresentation.etc.). I'm not very clear on what the "parameter" hints mean when they pop up in the editor.

Again, I really appreciate the help! What can I do for you? I doubt I can give you any programming tips! Does it help you if I keep going to your website to watch the free videos? I'm sure it would help me :-)