Trying to get all shapes from a slide with C#

  • Thread starter Thread starter S.Creek
  • Start date Start date
S

S.Creek

Hi,

i am writing a C# automation program that needs to identify all shapes
on a specific slide,
The shapes can be identified by a tag .? or by setting a type.?
(Possible?)
I appreciate if someone can refer me or to put some C# code examples
that demonstrate that.

The main issues I face are:

1. How to add a tag to a picture i put in the presentation.
2. How to loop all shapes on the slide and identify who are the
pictures carries the tag i assigned earlier.

Thank you

S.Creek
 
S.Creek said:
Hi,

i am writing a C# automation program that needs to identify all shapes
on a specific slide,
The shapes can be identified by a tag .? or by setting a type.?
(Possible?)
I appreciate if someone can refer me or to put some C# code examples
that demonstrate that.

The main issues I face are:

1. How to add a tag to a picture i put in the presentation.
2. How to loop all shapes on the slide and identify who are the
pictures carries the tag i assigned earlier.

It's certainly possible. In VB or VBA here's how; you'll have to do the C#
translation yourself:

Assuming you've added a picture and have a refeerence to it in oSh (dimmed as
Object or PowerPoint Shape):

oSh.Tags.Add "MyTagName", "MyTagValue"

Then

For Each oSh in oSl.Shapes
If oSh.Tags("MyTagName") = "MyTagValue" Then
' you've found it, do your stuff
End If
Next

If you examine .Tags("SomeName") for a shape with no tag of that name or with
no tags at all, it simply returns an empty string (or possibly null if you're
doing this in C/C# - easy enough to test which). It won't throw an error
though.

Each shape, slide or presentation can have any reasonable number of tags. It's
not limited to one per.
 

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

Back
Top