VBA for Powerpoint question

A

avfc4me

I want to do this:

slide 1 (a, b, c, d)
slide 2(a, c)
slide 3(a, b, d)
slide 4(b, d)

I want to then look through the list, and, depending on which presentation
audience (indicated by the a, b, c, or d) I want to construct the
presentation for, I want to write code that says, look at each slide, and
copy all the slides with the indicator "c" into a new, blank presentation.

The slides already exist in master presentations. I don't want to merely use
the "custom show" feature in PowerPoint because I want the slides in a
separate presentation each time I use them because they will require further
modifications once I create them, and I don't want to simply open a separate
master every time I want to work on my presentations because I will want to
make global changes on occassion.

I've perused the PowerPoint Help but I'm not getting anywhere. I'm new to
VBA and new to programming and need some hints as to where to start. I
thought I needed to do an array, and then a if...then statement, but I can't
get it to work.

Does someone have a hint for me? Point me in the right direction?

Much thanks,
 
D

David M. Marcovitz

First step: How will you code the fact that a particular slide is in
presentation a, b, c, d? Will you just know this (based on your list
below (I assume not because with four slides, you can just copy the
presentation and delete slides, so I'm guessing your four slides was an
example)?

You will need to mark each slide in some way that lets you know that it
is in presentation a, b, c, and/or d. You could have a named text box on
each slide (even off the viewable area of the slide), or you could use
tags, or ...

Once you know how the slide is marked, the VBA should be pretty easy.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
A

avfc4me

Oops. I think I just posted an answer that did nothing but quote your
question. Still finding my way around this site.

I don't know what tags are; where would I find info on those? Also, how
would one use a "named" text box?

You're right, there are 6 master presentations, all with between 30 and 60
slides each...which is why I didn't want to do the copy and paste thing. What
I HAD been doing was copying the whole presentation and then using vb
assigned to buttons to DELETE the slides that weren't supposed to be there,
but every time a slide is added...well. Can you say, "ICK!"

David, is there a similar solution in your book? If so, I'll hop in the car
and fly to Borders THIS SECOND to get it.
 
A

avfc4me

David M. Marcovitz said:
First step: How will you code the fact that a particular slide is in
presentation a, b, c, d? Will you just know this (based on your list
below (I assume not because with four slides, you can just copy the
presentation and delete slides, so I'm guessing your four slides was an
example)?

You will need to mark each slide in some way that lets you know that it
is in presentation a, b, c, and/or d. You could have a named text box on
each slide (even off the viewable area of the slide), or you could use
tags, or ...

Once you know how the slide is marked, the VBA should be pretty easy.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
A

avfc4me

Okay, I took your suggestion and I've been trying to get this to work, I've
solved countless errors but each solved error brings a new one and now I'm
just plain stuck. Anyone have a clue what I'm doing wrong here?

Public Sub CommandButton1_Click()
' Open the MasterPresentation
Set oMasterPres =
Presentations.Open("C:\PresentationMaker\employee_promo_master2.ppt")

ActivePresentation.Slides(1).Tags.Add "ABC"
ActivePresentation.Slides(2).Tags.Add "BCD"
ActivePresentation.Slides(3).Tags.Add "D"
ActivePresentation.Slides(4).Tags.Add "ABD"

Dim oNewPres As Presentation
Dim oNewSld As Slide
Dim oMasterPres As Presentation
Dim oMasterSld As Slide
Dim sSlideType As String
' Create a new presentation
Set oNewPres = Presentations.Add
For Each oMasterSld In oMasterPres.Slides
If Len(oMasterSld.Tags("IncludeIn")) = "A" Then
oMasterSld.Copy
oNewPres.Slides.Paste
End If
Next ' Master Slide
' close the master presentation
oMasterPres.Close


Unload PrAud3m

End Sub
 
A

avfc4me

yes! That made sense as soon as you said it, and does seem to work.

Now, I'm getting "type mismatch" from

If Len(oMasterSld.Tags("IncludeIn")) = "A" Then

I think it's because "ABC" doesn't actually = "A", yes? So how would I say,
rather than an equal to, but if "IncludeIn" CONTAINS the letter "A"? Or have
I misdiagnosed the problem?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top