How to refer to an ActiveX control on a named slide?

G

Guest

Here is a simplified version of my situation.
I have a combo box called cboMyCombo on a slide whose default name of
"Slide6" was changed to "MySlide" using the following code in a macro:
ActiveWindow.View.Slide.Name = "MySlide"

In the VBA project window, under the category of "Microsoft PowerPoint
Objects", the slide is still listed as "Slide6", while in the Properties
pane, the (Name) property correctly shows the name as "MySlide".

I also have a code module with a routine that needs to access the properties
of cboMyCombo. I have found that I can do this with the following syntax:
Slide6.cboMyCombo.<propertyName>

I would have thought that after changing the name of the slide, I could do
the following:
MySlide.cboMyCombo.<propertyName>
but that doesn't work.

Is there some way in code that I can refer to ActiveX objects on a renamed
slide using the new name? I can access autoshapes with the following:
ActivePresentation.Slides("MySlide").Shapes("MyShape").<propertyName>...
but I cannot find a similar syntax for ActiveX controls.

Does anyone have any idea how I can use my own more meaningful name in code
rather than the default "Slide6"?
 
S

Shyam Pillai

Check out this page:
Reference an ActiveX control on a slide in VBA
http://skp.mvps.org/ppt00042.htm

When you refer to the shape in this fashion -
Slide6.cboMyCombo.<propertyName> - you are qualifying the shape with the
parent objects. Slide6 is a slide object and the Name is a property of the
slide hence even after you rename the slide you cannot use that as a object
reference.
 
G

Guest

Shyam,

Thank you very much! This is exactly what I needed. I have visited your
website many times before. I don't know how I missed this.

I got it to work as:
ActivePresentation.Slides("MySlide").Shapes("cboMyCombo").OLEFormat.Object.<propertyName>

It is not as clean as it would be if PowerPoint would allow us to actually
rename the slide object, but this will work.
 

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