Programmatically modifying a shape drawn with freeform tool?

R

redhorse

Some time ago, I posted a few questions regarding a project to create a shape
properties editor so that I could change the name of a shape while in slide
view. The solution I arrived at works wonderfully for standard autoshapes
(such as rectangles), but when I try to use it on a closed shape drawn with
the freeform tool it fails. From what I can gather, it looks like PowerPoint
doesn't even recognize the freeform shape as a shape at all.

For example, the following will retrieve the name of a standard autoshape,
but will generate an error as if no shape is selected if I use it with a
closed shape drawn with the freeform tool:
ActiveWindow.Selection.ShapeRange(1).Name

Does anyone have any idea how I can programmatically access the properties
of a freeform shape? Does this particular kind of object fall into a
different branch of the PowerPoint object model? It seems to me that it
should work the same way since I can change the fill color and line color of
freeform shapes easily through the PowerPoint GUI.
 
R

redhorse

I think I figured it out already. It had to do with the way I was working
with other shapes. The error came from me trying to access the textRange of
the freeform shape, which cannot have a textRange.

So, the quesiton becomes, how can I differentiate between a standard
autohape that has a textRange and a freeform shape that doesn't?
 
R

redhorse

Never mind... I just figued it out.

In case anyone else runs into this problem, the shape's type can be
determined by the following:
ActivePresentation.Slides(ActiveWindow.View.Slide.SlideIndex).Shapes(ActiveWindow.Selection.ShapeRange(1).Name).Type

If this is equal to msoAutoShape, it is an autoshape. If it is equal to
msoFreeform, it is a freeform shape.
 

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