PDA

View Full Version : Object names



Kicker
05-07-2007, 04:42 PM
In PowerPoint 2000, what I want to do is a snap. I just use the properties window and name various objects anything I want to. But in 2003 and 2007, I am having a heck of a time.

I have a need to place various objects (clipart, circles, squares, freedrawn objects, etc) on a slide and then control their actions using VBA from various hotspots (command buttons, labels, etc) spread around the slide.

Using the normal actions won't work. I need to use VBA and control everything including fading objects in and out and moving them around the slide.

Need help:banghead: :banghead: :dunno :banghead: :banghead:

Brandtrock
05-07-2007, 05:57 PM
If I understand you correctly, in 2000 you can get things to work the way you want, but not in 2003 and 2007.

Do you have any code you can post?

What isn't being done (specifically) that you want done?

Regards,

Kicker
05-07-2007, 06:09 PM
Unfortunately, I cannot send you a copy of the slide as it is very sensitive and I would get into a whole lot of trouble. However, there is the code for one out of over 25 command buttons.

Private Sub CommandButton10_Click()
If ActivePresentation.Slides(1).Shapes(11).Visible = msoTrue Then
ActivePresentation.Slides(1).Shapes(11).Visible = msoFalse
Else
ActivePresentation.Slides(1).Shapes(11).Visible = msoTrue
End If
End Sub

Rather than call it commandbutton10, I would like to call it cmdPop5 and have the shape named area5.

I have a project coming up that will have more than 100 slides and probably over 10+ shapes controlled by VBA. Being able to call them by name would make it a lot easier.

Brandtrock
05-08-2007, 12:02 AM
I don't have 2007 yet, but in my PowerPoint 2003, the VBE doesn't display the Properties window when it first launches. Once I display it, I can do manipulations on all of the visible properties of control toolbox controls and Forms controls but not shapes. The command button issue you describe should be able to be addressed through the properties window. Or were you trying to rename these via code?

I'm still mulling over the shapes issue, although it appears to be the same in 2000 and 2003. How were you naming shapes in 2000?

I haven't played around with the differences in the actions for the shape objects between the two versions. I generally learn something (or several things) about PowerPoint every time I open it. :rotlaugh:

Regards,

Bob Phillips
05-08-2007, 05:16 AM
What exactly are you having problems with? Are you not able to rename the button, or not able to control the shapes with it. AS Brandtrock says, you should be able to rename the button in the VBE, just double-click it in design.

John Wilson
05-08-2007, 07:22 AM
As the others said you can rename control object in the property window.

You can name shapes with vba see below but also shapes have a default name eg "rectangle 1" which you can use as .shapes("rectangle 1"). If you install the select multiple objects tool (see "add a command to a toolbar" on Powerpoint alchemy) you can read this name from the menu.

Sub namer()
Dim strname As String
On Error GoTo errhandler
If ActiveWindow.Selection.ShapeRange.Count <> 1 Then Exit Sub
strname = InputBox("Name the shape")
ActiveWindow.Selection.ShapeRange.Name = strname
Exit Sub
errhandler:
MsgBox "There's an error - probably you didn't select a shape?"
End Sub

Kicker
05-11-2007, 11:29 AM
I think I have had a little brain malfunction. Didn't get notifications that there were some answers to the thread. Sorry.

Another malfunction is that I was previously naming objects in Excel, not PowerPoint. However, with that "figured out" I just started making a cross reference list for my object names.

This weekend I am going to post another question with an example of a slide I need help with making the Timer() function work with the named objects.