VBA function to determine if slide has a picture

S

sbarrett

I am currently using this function to determine if a slide has a
picture on it:

Private Function hasPicture(sld As Slide) As Boolean
Dim s As Shape
For Each s In sld.Shapes
If Left(s.Name, 7) = "Picture" Then
hasPicture = True
Exit Function
End If
Next s
hasPicture = False
End Function

This relies on PowerPoint's naming conventions, but Shape::Name can be
set to anything by a programmer. Is there a property that is more
reliable? I tried using OnError with the PictureFormat property, but
it appears that you cannot stop an error message. There's a HasPicture
property, but it's only on my Christmas wish list ;o) TIA --Sam
 
S

Shyam Pillai

Are you specifically looking for shape types then you can locate then using
the msoPicture and msoLinkedPicture type. If you want to check if a given
shape has picture fill then you can check by querying the fill type for the
shape:
Activewindow.Selection.ShapeRange.Fill.Type=msoFillPicture
 

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