PC Review


Reply
Thread Tools Rate Thread

Another VBA Question: Find text, delete the slide with that text?

 
 
=?Utf-8?B?YXZmYzRtZQ==?=
Guest
Posts: n/a
 
      28th Mar 2007
I have two command buttons; I want one to look for the slide that has the
word "Jones" and delete that slide.

This is just one of the variations I've tried:

Public Function GetJones()
FindWhat = "Jones"
Dim Sld As Slide
Sld.Cut
End Function

I would be grateful for another hint as to what I'm missing here, Oh
PowerPoint Masters.

(And maybe someone could suggest a book for those of us that find us
wandering into the middle of these things without getting the basics down
first? Yes, that would be me, guilty as charged...)


 
Reply With Quote
 
 
 
 
David M. Marcovitz
Guest
Posts: n/a
 
      28th Mar 2007
Unfortunately, there aren't a lot of good books for using VBA in
PowerPoint. In fact, there is really only one book, and it just gets your
started with the basics. I'll let others tell you if it is any good or
not because I wrote it. You can find it at
http://www.PowerfulPowerPoint.com/

As for your question, you want to cycle through the slides and look for
the text "Jones." There are a lot of ways to do this. If you're only
looking for one instance of Jones, then this will work. If you want to
delete more than one slide at the same time, you'll have to cycle
backwards through the slides, instead of forward (as I did with the For
Each). Also if you want to match whole words and capitalization, look at
the optional parameters for the Find method that I used (as my procedure
will kill the first slide it finds with jonestown):

Sub KillJones()
Dim oSld As Slide
Dim oShp As Shape
For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.HasTextFrame Then
If oShp.TextFrame.TextRange.Find("Jones") Is Nothing Then
'didn't find it
Else
'found it
oSld.Delete
Exit Sub
End If
End If
Next oShp
Next oSld
End Sub


--
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/

=?Utf-8?B?YXZmYzRtZQ==?= <(E-Mail Removed)> wrote in
news:5A537B8F-1F09-434E-AFC1-(E-Mail Removed):

> I have two command buttons; I want one to look for the slide that has
> the word "Jones" and delete that slide.
>
> This is just one of the variations I've tried:
>
> Public Function GetJones()
> FindWhat = "Jones"
> Dim Sld As Slide
> Sld.Cut
> End Function
>
> I would be grateful for another hint as to what I'm missing here, Oh
> PowerPoint Masters.
>
> (And maybe someone could suggest a book for those of us that find us
> wandering into the middle of these things without getting the basics
> down first? Yes, that would be me, guilty as charged...)
>
>
>


 
Reply With Quote
 
New Member
Join Date: Jun 2011
Posts: 1
 
      21st Jun 2011
Quote:
Originally Posted by David M. Marcovitz View Post

Sub KillJones()
Dim oSld As Slide
Dim oShp As Shape
For Each oSld In ActivePresentation.Slides
For Each oShp In oSld.Shapes
If oShp.HasTextFrame Then
If oShp.TextFrame.TextRange.Find("Jones") Is Nothing Then
'didn't find it
Else
'found it
oSld.Delete
Exit Sub
End If
End If
Next oShp
Next oSld
End Sub


--
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/

=?Utf-8?B?YXZmYzRtZQ==?= <(E-Mail Removed)> wrote in
I have a presentation with a certain no. of slides. I have an array (string in vba) which has the names of the slides which are not required. Each slide is assigned a name in a textbox in the presentation. I want to delete those slides whose names are there in the array. The array is dynamic. So it might have 3 names today and 4 names tomorrow. How do I delete the slides based on the array?? Pls Help
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Link text boxes in slides / text flow from slide to slide. Satadru Microsoft Powerpoint 1 14th Jul 2009 01:08 PM
How do you delete a text box in the slide pane Beeftrie Microsoft Powerpoint 2 7th Dec 2008 01:58 AM
Re: Delete a text box from a slide Bill Foley Microsoft Powerpoint 0 21st Dec 2006 05:20 PM
Re: Delete a text box from a slide David M. Marcovitz Microsoft Powerpoint 0 21st Dec 2006 04:39 PM
Macro to find text, then delete entire line containing the text? =?Utf-8?B?VGFpbGluZ3M=?= Microsoft Word Document Management 2 16th Sep 2006 03:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:33 AM.