Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / February 2006

Tip: Looking for answers? Try searching our database.

How to access CommandButton properties in different slides

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
thomas.schoenfelder@cyberfun.de - 20 Feb 2006 20:01 GMT
I'm working on a Quiz Game with PP2003.

The following code changes the picture of a CommandButton (cuurent
slide only) when clicking on it

""
Private Sub CommandButton1_Click()

CommandButton1.Picture = LoadPicture("D:\MyPicture.jpg")

End Sub
""

Along with this click I want to change pictures of all other
CommandButtons on other slides.

I tried something like this:
ActivePresentation.Slides(4).CommandButton1.Picture =
LoadPicture("D:\MyPicture.jpg")

but it wont' work.

??? How do I accesss properties of all other CommandButtons I have in
other slides ???
David M. Marcovitz - 20 Feb 2006 20:18 GMT
Instead of ActivePresenations.Slides(4), you want Slide4 as in:

Slide4.CommandButton1.Picture = LoadPicture("D:\MyPicture.jpg")

You also want to be careful about specifying an absolute path for the
picture. When you move/distribute the presentation, MyPicture.jpg isn't
necessarily going to be on the D drive.

--David

Signature

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/

thomas.schoenfelder@cyberfun.de wrote in news:1140465697.411060.72640
@g44g2000cwa.googlegroups.com:

> I'm working on a Quiz Game with PP2003.
>
[quoted text clipped - 20 lines]
> ??? How do I accesss properties of all other CommandButtons I have in
> other slides ???
thomas.schoenfelder@cyberfun.de - 20 Feb 2006 20:33 GMT
Dave,

Thanks for the quick reply

"Slide4.CommandButton1.Picture = LoadPicture("D:\MyPicture.jpg")"
returns an error "Object missing"

Do I have to define a Public Sub instead of a Private Sub to get global
access to all CommandButtons ?
David M. Marcovitz - 20 Feb 2006 20:38 GMT
No, you do not need a public sub because the object itself is, in some
ways, public. You must have an existing CommandButton1 on slide 4 for
this to work. Are you sure there is a something called CommandButton1 on
slide 4? This exact code worked for me (except I did it on Slide1 and
used a different picture).
--David

Signature

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/

thomas.schoenfelder@cyberfun.de wrote in news:1140467618.334978.254950
@g43g2000cwa.googlegroups.com:

> Dave,
>
[quoted text clipped - 5 lines]
> Do I have to define a Public Sub instead of a Private Sub to get global
> access to all CommandButtons ?
thomas.schoenfelder@cyberfun.de - 20 Feb 2006 21:13 GMT
Dave,
Thanks a lot, you saved my day

Now it works  :-))))

Now to be flexible on the number of slides I want to use a Variable
(SL_Name) instead of Slide1 ... Slide9

something like this...
"
Sub Cancel_Joker()

 NrSlides = ActivePresentation.Slides.Count
  For i = 1 To NrSlides
    SL_Name = ActivePresentation.Slides(i).Name
    SL_Name.Button_5050_1.Picture = LoadPicture("MyPic.jpg")

 Next i

End Sub
"
How do I need to define/use this variable (SL_Name) to make this code
work

regards

Thomas
David M. Marcovitz - 20 Feb 2006 21:30 GMT
I was afraid you were going to ask that. I don't know the answer.
Hopefully, one of the more advanced VBA experts will chime in with an
answer.
--David

Signature

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/

thomas.schoenfelder@cyberfun.de wrote in news:1140469994.859717.31550
@g44g2000cwa.googlegroups.com:

> Dave,
> Thanks a lot, you saved my day
[quoted text clipped - 23 lines]
>
> Thomas
Steve Rindsberg - 21 Feb 2006 01:56 GMT
How about this:

Dim oSl as Slide

For Each oSl in ActivePresentation.Slides
 With oSl.Shapes("CommandButton1")
   .OLEFormat.Object.Picture = LoadPicture("c:\pix\yourpicture.jpg")
 End With
Next

If you can get an object reference to the shape that represents the control
(button, textbox, whatever) then tack on .OLEFormat.Object and carry on as
though you're setting properties in the control's property sheet or click event
handler.

> Dave,
> Thanks a lot, you saved my day
[quoted text clipped - 23 lines]
>
> Thomas

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
thomas.schoenfelder@cyberfun.de - 21 Feb 2006 21:36 GMT
Steve,

thanx a lot, your fix works great.
that's exactly what I was after.

best regards

Thomas
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.