Reference an activex control

P

PeterM

Hi .
If I have a label on a slide how can i reference it in vba.
Eg an oval on a slide rotates how do i get the label to give its rotation?
 
D

David M. Marcovitz

Items from the control toolbox are referenced in VBA via their slide
numbers. For example, the first label you add to slide 7 will be
referenced via Slide7.Label1

The content of the label is the Caption. You can change teh caption with
Slide7.Label1.Caption = "Whatever you want"

Next, you need to get the rotation of your Oval, which can be done
something like this:

Slide7.Label1.Caption = ActivePresentation.Slides(7).Shapes(2).Rotation

assuming that your oval is shape #2 on slide 7.

--David
--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
P

PeterM

Sorry David I just tried it and it only showed 0 is there away to have it
update say with the degrees of rotation.
Cheers
 
D

David M. Marcovitz

You're probably referencing the wrong shape, or your not running the
macro after the shape has been adjusted. For example, if your shape is
not the #2 shape, then Shapes(2) won't give you the right rotation. You
might want to give the shape a name and use that instead of the number
(see Example 8.7 on my site for naming shapes).

The other issue I mentioned was running the macro. Note the macros don't
necessarily run themselves so you have to figure out when you want to
trigger the macro to update the label.

--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 
P

PeterM

Hi David,
The shape is correct.
If I stop the slideshow and change it's rotation it is correct.
I am not sure how to write the macro to update whilst the show is running.
or if it is possible.
Cheers
 
D

David M. Marcovitz

How are you rotating the shape during the slide show? Do you have a macro
that does that? Or I am misunderstanding what you are doing?
--David

--
David M. Marcovitz
Microsoft PowerPoint MVP
Director of Graduate Programs in Educational Technology
Loyola College in Maryland
Author of _Powerful PowerPoint for Educators_
http://www.PowerfulPowerPoint.com/
 

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