Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / May 2007

Tip: Looking for answers? Try searching our database.

How do i find if a shape "xyz" is on Selected slide with vba

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chuck [Sbc) - 14 May 2007 20:07 GMT
I am using a macro which scans all of the slides in a presentation to make
changes to a given shape (Named).  I would like to know if the selected
slide contains a shape (textbox) with the name of "xyz" If it does, I want
to skip that slide.
Steve Rindsberg - 14 May 2007 22:54 GMT
> I am using a macro which scans all of the slides in a presentation to make
> changes to a given shape (Named).  I would like to know if the selected
> slide contains a shape (textbox) with the name of "xyz" If it does, I want
> to skip that slide.

One simple way is to call a function that finds the shape on the slide, if it
exists.  It's probably more generally useful than just testing to see if the
shape exists or not; you may want to do something with the shape in other
macros, and the same function can be used to get the shape and work with it.

Say you're in a loop like:

Dim oSl as Slide
Dim oSh as Shape

For each oSl in ActivePresentation.Slides
 Set oSh = GetShape(oSl, "xyz") Then  
 If oSh Is Nothing Then   ' no shape by that name
    ' do your stuff here
 End If
Next   ' oSl

Function GetShape(oSl as Slide, sShapeName as String) as Shape
' Returns the shape named sShapeName on oSl
' or nothing if the shape doesn't exist
  On Error Resume Next
  Set GetShape = oSl.Shapes(sShapeName)
End Function

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
Chuck [Sbc) - 16 May 2007 15:30 GMT
Thanks - Worked just right,
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.