Name of the objects and Object types

H

Hari Prasadh

Hi,

I have primarily used Excel (with a little VB).
This is my introduction to powerpoint.

I am copying some ranges (containing some text) from Excel and pasting in to
powerpoint.

I want to copy this text from excel and paste it within a specific textbox
within a powerpoint template.

How do I know the name of the textbox in the powerpoint template.

I see that if I run some dummy macro recording's then I get some code like
ActiveWindow.Selection.SlideRange.Shapes("Text Box 8").Select

Is there a more efficient way of knowing the name of the objects and object
numbers in powerpoint(rather than recording macros for each object and
seeing the description inside Shapes("Text Box 8"). )

Also, is there a separate group for powerpoint programming? (My OE doesnt
say so)

Thanks a lot,
Hari
India
 
S

Shyam Pillai

Hari,
You don't need to know the name of the shape enter text into it. You can use
the index number of the shape too.
ActiveWindow.Selection.SlideRange.Shapes(1).TextFrame.TextRange.Text = "This
is a test.
' Assuming that you intend to paste the text from the clipboard.
ActiveWindow.Selection.ShapeRange(1).TextFrame.TextRange.Paste

I would recommend that you spend some time visiting the pages at the
following sites: http://skp.mvps.org and the programming section of the
PowerPoint Faq - www.pptfaq.com
 
H

Hari Prasadh

Hi Shyam,

I have gone through your site and found syntaxes in the newbie section
useful to me.

My following question would be a very naive one for you. You have asked me
to use the index number of the shape. How would it be possible for me to
know the index number of the shape non-programmatically. Please guide me.

Analogy is that in Excel if I have a embedded chart and if I keep the Ctrl
pressed and select one of the chart, Name-Box would say Chart 1 or Chart 2.
Do we have such Name-Boxes in Power-point?

(Please note , programmatically I have been able to know the index number of
the shape in an indirect manner by using the Sub
Object_Types_on_This_Slide() from rpdslides.com -- FullFaq's list)

Thanks a lot,
Hari
India
 
H

Hari Prasadh

Hi Shyam,

Im sorry. Even programmatically Im not able to find the shape number --
Shapes(1) -- as the macro Object_Types_on_This_Slide() from rpdslides.com
gives me the type number and the name of the object but not the shape
number.

Please tell me the syntax for finding the shape number of an object
programmatically. (also for finding the same non-programmatically)

Thanks a lot,
Hari
India
 
S

Shyam Pillai

Hari,
The index number corresponds to the z-order position of the shape on the
slide. The bottom most shape will have the index as 1 and the top most shape
as N where N = number of shapes on the slide. You can ascertain the index
number by making use of a hidden utility - Select Multiple Object.

1. Select Tools | Customize..| Commands Tab.
2. Under catergories click on 'Drawing'.
3. Draw 'Select Multiple Objects' command from the right column to a toolbar
of your choice.
4. Close the Customize dialog.
5. Click on the new command button you've added.

This will enumerate the shape in order of their index numbers.
Do we have such Name-Boxes in Power-point?
Not quite, but you can download my free rename add-in which has a name box.
Download it from here: http://skp.mvps.org/download.htm

--
Regards,
Shyam Pillai

Handout Wizard: http://skp.mvps.org/how
 
H

Hari Prasadh

Hi Shyam,

Im sorry .. -- shapes(i) -- is there in the code of
Object_Types_on_This_Slide() from rpdslides.com
So Im able to find the shape number programmatically by using -- Msgbox i --

Thanks a lot,
Hari
India
 
H

Hari Prasadh

Hi Shyam,

Select Multiple Object is a nice method to know about the index number.

But based on your -- The bottom most shape will have the index as 1 and the
top most shape as N where N = number of shapes on the slide. -- I have new
doubts.

In the first slide of my presentation I have 3 shapes and all these 3 are
text-boxes.

When I click on the Select multiple objects, then I have 3 checkboxes within
that:-
Text Box 8: Hello
Text Box 9: World
Text Box 10: Bye

My doubt is that if there are only 3 shapes then why are the numbers above
8, 9 and 10 instead of 1, 2 and 3?
Morever the text in the top most text-box is hello, while the text in the
middle text-box is world and the text in the third text-box is Bye. So why
is the select multiple option utility giving a higher number to the
bottom-most text-box.

(I have Office XP and Win XP.)

Thanks a lot,
Hari
India
 
H

Hari Prasadh

Hi David,

Thnx a ton for the link.

I went through all the example powerpoint files in your site and pinched
some of the syntaxes in them for my needs.

Regards,
Hari
India
 
H

Hari Prasadh

Hi Shyam,

I see that Select multiple objects is a GREAT way to select *hidden*
objects. Like I was just playing around and had a rectangle and over it I
created a big table which hid the rectangle from view and using the multiple
object view I could select the rectangle and edit the Text in that.

Just wanted to know this. Is there any other non-programmatic way to
accomplish the above. (Programmatically I can do it based on swiping codes
from here and there.)

Thanks a lot,
Hari
India
 
S

Steve Rindsberg

In the first slide of my presentation I have 3 shapes and all these 3 are
text-boxes.

When I click on the Select multiple objects, then I have 3 checkboxes within
that:-
Text Box 8: Hello
Text Box 9: World
Text Box 10: Bye

My doubt is that if there are only 3 shapes then why are the numbers above
8, 9 and 10 instead of 1, 2 and 3?

Text Box 8 and the others are the .Name property of the shape and have nothing
to do with its .Index

If you change the order of the shapes (Draw, Order, Send to back, etc) then
index changes but not the name.
Morever the text in the top most text-box is hello, while the text in the
middle text-box is world and the text in the third text-box is Bye. So why
is the select multiple option utility giving a higher number to the
bottom-most text-box.

PPT assigns the number portion of the .Name property in order as the shape is
created. The number itself is all but meaningless.
 
D

David M. Marcovitz

If you really want to know the number of a shape, here is how you do it:

If you are using PowerPoint 2002 or 2003, go to the Tools menu and choose
Options. Click on the Edit tab, and check the box under Disable new
features for the new animation features. This step is unnecessary in
PowerPoint 2000 or 97.

Now, go to the SlideShow menu and choose Custom Animation. Click on the
Order and Timing tab. Look in the upper left corner of the dialog box,
and you will see all the shapes on the slide. Ignore the names of those
shapes (they are not the real names of the shapes), but they are followed
by a number. That number is the Index number of the object.

As earlier posts have mentioned, using the number is not reliable because
it can change as objects are added to and deleted from your slide.

--David

--
David M. Marcovitz
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
H

Hari Prasadh

Hi David,

Thnx a lot for a step by step explanation.

You (and everybody else) have advised to not use the number of a shape as
addition / deletion of new objects will change the shape number.

I have one doubt based on above. Iam quoting Steve R here-- If you change
the order of the shapes (Draw, Order, Send to back, etc) then index changes
but not the name. -- Then if I use Index number in my program wouldn't it go
wrong if the order of the shapes was changed by somebody prior to the
running of the macro?.

In all what number would be the best choice for programmatically refferring
to a shape?

Thanks a lot,
Hari
India
 
D

David M. Marcovitz

The best thing to do is to use the name, particularly if other users
might mess with stuff. Note that there are a couple of numbers of
interest. The index number is just a plain number, used as:

ActivePresentation.SlideShowWindow.View.Slide.Shapes(3)

That gives you the third shape on the current slide. That number is
subject to change.

Another number you will see is part of the name as in:

ActivePresentation.SlideShowWindow.View.Slide.Shapes("AutoShape 3")

That gives you a shape named "AutoShape 3" on the current slide. That
number is assigned to the name when the shape is created, and it never
changes (unless you change it). It is just used by PowerPoint to insure
that it is not creating shapes with the same name on the same slide.

--David

--
David M. Marcovitz
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.loyola.edu/education/PowerfulPowerPoint/
 
S

Steve Rindsberg

You (and everybody else) have advised to not use the number of a shape as
addition / deletion of new objects will change the shape number.

I have one doubt based on above. Iam quoting Steve R here-- If you change
the order of the shapes (Draw, Order, Send to back, etc) then index changes
but not the name. -- Then if I use Index number in my program wouldn't it go
wrong if the order of the shapes was changed by somebody prior to the
running of the macro?.

Exactly. That's why everybody's advising against using the number (ie, the
Index).
In all what number would be the best choice for programmatically refferring
to a shape?

Use the .Name

The fact that the .Name is made up of text and a number -- ie, Rectangle 42 --
isn't relevant.

If you want a name that's easier to remember, change the .Name of the shape.
 
S

Shyam Pillai

Things to remember when referring to shape by their names:
1. Bug in PowerPoint: If you have renamed a shape using vba, a copy/paste of
that shape will create a shape with the same.
2. I've seen presentations where a call to get the reference to a shape by
name will fail even if the shape with that name exists. Hence I've given up
on using names. If you are deploying your code to several machines, I'd urge
you to do so. For simple purposes using names is just fine.

--
Regards,
Shyam Pillai

Handout Wizard: http://skp.mvps.org/how
 
H

Hari Prasadh

Hi Shyam,

Thnx for giving me the below info. Would be careful about the same.

Thanks a lot,
Hari
India
 
H

Hari Prasadh

Hi Steve and David,

Thnx for clearing all my doubts regarding Name and Index numbers.

Regards,
Hari
India
 
H

Hari Prasadh

Hi,

Since, the present lot of doubts seemed to be more or less related to the
original post, I did not resort to a new thread.

I open a new PPT session from Start - Programs.

I get a blank presentation with one slide, where there is one dotted
rectangle border with -- Click to add title-- and another dotted rectangle
border saying -click to add subtitle--

STEP 1 - I click on select multiple object menu shortcut and I see that
these 2 dotted rectangle border shapes are called as Rectangle 2 and
rectangle 3.

STEP 2 - Then I went to the drawing toolbar and clicked on rectangle shape.
In -- select multiple objects-- menu bar it's name is displayed as Rectangle
4

STEP 3- Then I went to Insert and selected a Text Box and drew the same on
the first slide. As soon as I unselected the textbox it was no longer on the
slide. I checked -- select multiple objects-- menu bar and it displayed
text-box as being not there on the slide.

STEP 4 - Since in STEP 3 I couldnt get a textbox so this time before
unselecting the text-box I wrote some text inside it.In -- select multiple
objects-- menu bar it's name is displayed as Text-Box 5.

STEP 5 - I go to --Slide show -- Custom animation - and within check to
animate slide objects I get the following four objects (in order ) -- Title
1 , Text 2 , Rectangle 3 and Shape 4 . By checking the check boxes in the
custom animation dialog box I note that MAPPING between the display names in
Cutom animation dialog box and the names in the select multiple objects is
:-
Title 1 is actually Rectangle 2
Text 2 is rectangle 3
Rectangle 3 is rectangle 4
Shape 4 is TextBox 5

Couple of naive doubts based on above.

a) Since I opened a new PPT session, why should PPT give the numbers as 2
and 3 instead of 1 and 2 in STEP 1. Any reason behind the same?

b) In STEP 2 I created a rectangle from drawing toolbar and in STEP 4 I
could create a Text-Box. Whats the difference between a Text-Box and a
rectangle. In what situation does one use a text-box and when a rectangle?.
I see that I cannot write anything within a rectangle. So, when we create a
flow-chart kind of thing using this rectangle do I have to use a textbox
over a rectangle in order to give the illusion of text written inside a
rectangle? Are there any better/other ways?

c) I see that in a text-box the outer line/border is not visible while in a
rectangle it is visible. Again the 2 shapes from STEP 1 have dotted border.
What does one do in powerpoint which requires these 3 shapes to have
different kind of border characteristics? Again if i write something within
the shapes of STEP 1 the doted border vanishes. what's the logic behind the
same. (ok, to some extent I can appreciate rectangle having border as that
would be needed in a flow-chart kind of situation. Other that is rectangle
of any use?)

d)In STEP 3 the textbox vanishes if I dont write anything inside it while it
stays put if I write something as in STEP 4. Why has it been designed in
such a manner?

e) I see that STEP 2 rectangle and STEP 4 text-box have a green handle when
I select them and with it I can rotate them to any angle. On the other hand
the STEP 1 rectangle dont have that green handle. Why is it so?

g) If in -- Select multiple objects-- menu bar displays the same name which
is Rectangle for both STEP 1 and STEP 2 objects then why are they having
different characteristics in terms of border/green hande etc? Please note as
of now I havent changed their names using Shyam's add-in, so I belive that
if Powerpoint by default shows something as rectangle then it must be a
rectangle. Is that a valid assumption?

h) Based on the DISPLAY name differences between custom animation dialog box
and select multiple objects menubar in STEP 5, I have some sub-questions:-
1) I understand that programmatically if I want to refer to a shape then
for small - scale purposes I would stick with the names in the select
multiple objects. But my doubt is ... is it posssible for a person to second
guess the name (not the number) which will be displayed in the custom
animation dialog box based on the default display name in the select
multiple objects. It's because in one of the posts David M said -- Ignore
the names of those shapes (they are not the real names of the shapes), but
they are followed by a number. That number is the Index number of the
object. -- So on what basis does Power-point assign names in the cutom
animation dialog box.
2) Is it possible for a person to know non-programmatically what is the
type/kind of a object. Like is it possible for me to second-guess by
clicking on a particular shape or by selecting some menu option whether a
particular shape is actually a text-box kind of shape or a rectangle kind of
shape. Between text-Box and rectangle difference would be that I cannot
write inside the later, but what about the huge number of shapes provided in
powerpoint, how do I know what type they are non-programmatically?

Please guide me.

Thanks a lot,
Hari
India
 
S

Steve Rindsberg

Hari,

You're very methodical and observant, and you ask lots of good questions. Some
of them don't have really good answers other than "That's just the way MS
designed it" but they generally designed it the way they did for good reason.

I'll give it my best shot.
STEP 3- Then I went to Insert and selected a Text Box and drew the same on
the first slide. As soon as I unselected the textbox it was no longer on the
slide. I checked -- select multiple objects-- menu bar and it displayed
text-box as being not there on the slide.

Earlier versions used to allow blank text boxes. This can cause other problems
later on, so now if you create a text box and don't enter any text, PPT deletes
the text box when you de-select it. This is A Good Thing. If you enter just
one character, even a space, the text box should stay there.
Cutom animation dialog box and the names in the select multiple objects is
:-
Title 1 is actually Rectangle 2
Text 2 is rectangle 3
Rectangle 3 is rectangle 4
Shape 4 is TextBox 5

Isn't PPT fun? Each shape has what you might call a "real" or "internal" name
that PPT assigns it when the shape's created. Each shape also has a .Name
property that is the same as the "real" name by default, but which can be
changed in code. The custom animation box shows the "real" names (or I think
in some cases the text in the shape?).
a) Since I opened a new PPT session, why should PPT give the numbers as 2
and 3 instead of 1 and 2 in STEP 1. Any reason behind the same?

Because it does. ;-)

There's something called "The Serenity Prayer" that starts out " ... grant me
the serenity to accept the things I cannot change"

That's pretty good advice for life and even better advice for life with
PowerPoint.
b) In STEP 2 I created a rectangle from drawing toolbar and in STEP 4 I
could create a Text-Box. Whats the difference between a Text-Box and a
rectangle. In what situation does one use a text-box and when a rectangle?.
I see that I cannot write anything within a rectangle.

A text box is in many ways just a special case of Rectangle. You could
consider it a rectangle that's been optimized for use as a text container,
since we so often need to do that. And of course, it REQUIRES text. You can,
by the way, enter text within a rectangle. Click it, start typing.
So, when we create a
flow-chart kind of thing using this rectangle do I have to use a textbox
over a rectangle in order to give the illusion of text written inside a
rectangle? Are there any better/other ways?

I'd just use a rectangle. And programmatically you access its text exactly as
you would a text box.

Shape.TextFrame.TextRange.Text = "Look at me! I'm writing in rectangles!"
c) I see that in a text-box the outer line/border is not visible while in a
rectangle it is visible.

Or not, depending on the defaults or attributes that you assign. The rectangle
can have no Line color, the text box can be given a line color and thickness.
Again the 2 shapes from STEP 1 have dotted border.
What does one do in powerpoint which requires these 3 shapes to have
different kind of border characteristics?

The shapes with the dotted border are placeholders, inherited from the slide
master. Until you type something into them or otherwise add content, they
don't really exist (they won't print or appear in slide shows). The dotted
outline, I suppose, indicates this ghostly quality of their tenuous existence.
<g>

Again if i write something within
the shapes of STEP 1 the doted border vanishes. what's the logic behind the
same.

By adding content, you've made it real. It will be forever grateful.
(ok, to some extent I can appreciate rectangle having border as that
would be needed in a flow-chart kind of situation. Other that is rectangle
of any use?)

As sub-parts of other drawings ... try drawing a building w/o rectangles, for
example. No fair using the Guggenheim Museum.
e) I see that STEP 2 rectangle and STEP 4 text-box have a green handle when
I select them and with it I can rotate them to any angle. On the other hand
the STEP 1 rectangle dont have that green handle. Why is it so?

That'd be the Title text placeholder, I think? I suppose MS saw no need for
rotating title or body text. In something like ten years of doing newsgroup
support for PPT and other similar programs, I don't recall anyone asking for
this feature. It makes sense then that they wouldn't implement it.
h) Based on the DISPLAY name differences between custom animation dialog box
and select multiple objects menubar in STEP 5, I have some sub-questions:-
1) I understand that programmatically if I want to refer to a shape then
for small - scale purposes I would stick with the names in the select
multiple objects. But my doubt is ... is it posssible for a person to second
guess the name (not the number) which will be displayed in the custom
animation dialog box based on the default display name in the select
multiple objects. It's because in one of the posts David M said -- Ignore
the names of those shapes (they are not the real names of the shapes), but
they are followed by a number. That number is the Index number of the
object. --

No, it's not. If you create three rectangles one after the other, they'll
likely be called Rectangle 1, 2 and 3. Send Rectangle 3 to the back and its
index number is now 1.

Create three rectangles, delete one, create another and it's now Rectangle 4,
but there's no shape at index 4.

Again: there is NO connection between names and Index numbers, other than a
very tenous one at the time the shapes are first created on a brand new slide.
So on what basis does Power-point assign names in the cutom
animation dialog box.

See earlier: in short, the shape name it assigns when the shape is created
plus the text in the shape, if any.
2) Is it possible for a person to know non-programmatically what is the
type/kind of a object. Like is it possible for me to second-guess by
clicking on a particular shape or by selecting some menu option whether a
particular shape is actually a text-box kind of shape or a rectangle kind of
shape. Between text-Box and rectangle difference would be that I cannot
write inside the later, but what about the huge number of shapes provided in
powerpoint, how do I know what type they are non-programmatically?

It will be obvious in some cases. In other cases, you might need to rely on
specific behaviors: if it looks like a rectangle and has no text in it, it's a
rectangle. If it has text in it and you delete the text, then if it
disappears, it's a text box. If it sticks around for more abuse, it's a
rectangle.

Hope that helps some.
 

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