Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBA - remove unused masters?

105 views
Skip to first unread message

Mel

unread,
Nov 2, 2009, 7:48:24 AM11/2/09
to
I'm using PPT 2003 and wanting to remove unused slide/title masters
from my presentations in an automated way. I may have a lot of masters
in a presentation and I have to do this frequently to shave off a few
megs. I thought PPT had a command to do that, but I can't find it. Is
there a way to do this with VBA?

Thanks,
Melina

Steve Rindsberg

unread,
Nov 2, 2009, 8:51:41 AM11/2/09
to
In article <01685d6d-fdea-4e03-9883-

Promise me you'll make a copy of your presentation first. Then try
this. It's a step above aircode, but not a very large step.

Sub DelUnusedDesigns()

Dim x As Long
Dim oDes As Design
Dim oSld As Slide
Dim bDesInUse As Boolean

With ActivePresentation
For x = .Designs.Count To 1 Step -1
Set oDes = .Designs(x)
With oDes
For Each oSld In ActivePresentation.Slides
If oSld.Design.Name = oDes.Name Then
bDesInUse = True
Exit For
End If
Next
If Not bDesInUse Then
oDes.Delete
End If
End With
Next
End With

End Sub


==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/

PPTools add-ins for PowerPoint
http://www.pptools.com/


Steve Rindsberg

unread,
Nov 2, 2009, 8:51:51 AM11/2/09
to
In article <01685d6d-fdea-4e03-9883-
cd7812...@15g2000yqy.googlegroups.com>, Mel wrote:

Promise me you'll make a copy of your presentation first. Then try

Chirag

unread,
Nov 2, 2009, 10:38:36 AM11/2/09
to
You need to reset bDesInUse and you can check for the design directly too
instead of comparing their names. Here is the modified code:

Sub DelUnusedDesigns()
Dim x As Long
Dim oDes As Design
Dim oSld As Slide
Dim bDesInUse As Boolean

With ActivePresentation
For x = .Designs.Count To 1 Step -1
Set oDes = .Designs(x)

bDesInUse = False


For Each oSld In ActivePresentation.Slides

If oSld.Design Is oDes Then


bDesInUse = True
Exit For
End If
Next
If Not bDesInUse Then
oDes.Delete
End If

Next
End With
End Sub

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html

"Steve Rindsberg" <ab...@localhost.com> wrote in message
news:VA.000053f...@localhost.com...

Steve Rindsberg

unread,
Nov 2, 2009, 2:45:42 PM11/2/09
to
In article <Oe9dLK9W...@TK2MSFTNGP06.phx.gbl>, Chirag wrote:
> You need to reset bDesInUse

Oops. I'd set a mental reminder to do that. I must have been out of my
mind when the alarm went off. Thanks, Chirag.

> and you can check for the design directly too
> instead of comparing their names.

Ah ... thanks again. "Is" instead of "=" ... neat.

Mel

unread,
Nov 12, 2009, 10:02:27 AM11/12/09
to
Fate has its funny ways! <lol> Actually, I needed both your ways of
doing this. I can check the designs in simpler instances, but will
need to check for like strings in the master names when opened in 2007
then transferred back to 2003 because of the hosing of the masters
going back and forth creates. It's complicated. <sigh>

Thanks to both of you!

Melina


On Nov 2, 1:45 pm, Steve Rindsberg <ab...@localhost.com> wrote:

0 new messages