Disabling/Inactivating Action Button or Image

  • Thread starter Thread starter Dr. Anis Karim
  • Start date Start date
D

Dr. Anis Karim

I have a presentation, which is linked from 2 other presentations; that is,
there are links to the presentation from the other 2. I would like to have
an Action Button or image on the slides in my presentation, which should be
visible/active only if the presentation is started by clicking on the link
in ONLY one of the other presentations. The button/image should be
invisible/disabled when my presentation is started from the second other
presentation. Is this possible? Sincere help requested.

Dr. Anis Karim
 
Welcome back Dr. Karim. How is the project doing?
The button/image should be
invisible/disabled when my presentation
is started from the second other
presentation. Is this possible?
Possible? Yes.
Easy? Well...

You would need to use VBA to check what other presentations are loaded (they
should be since they referred the program control to this one), then based
on the results, change a button object on the master slide to visible or
not. Are you familiar with VBA? If not check:
**How do I USE this VBA stuff in PowerPoint?
http://www.rdpslides.com/pptfaq/FAQ00033.htm

You would need code that looks something like this:

========Code========
Option Explicit

Sub WhosGotTheButton()
Dim X As Integer

'You will need to know the name or _
index number of the shape on the _
Master Slide that is the button.
With ActivePresentation.SlideMaster. _
Shapes("CommandButton1")
.Visible = msoFalse

For X = 1 To Presentations.Count
'Replace "My Pres.PPT" with the name of _
the presenttion that will trigger the _
button to be visible.
If Presentations(1).Name = "My Pres.PPT" Then
.Visible = msoTrue
With SlideShowWindows(1).View
.GotoSlide (.CurrentShowPosition)
End With
End If
Next X
End With

End Sub
======End========

Post back if you need additional help with this.


--
Bill Dilworth, Microsoft PPT MVP
===============
Please spend a few minutes checking vestprog2@
out www.pptfaq.com This link will yahoo.
answer most of our questions, before com
you think to ask them.

Change org to com to defuse anti-spam,
ant-virus, anti-nuisance misdirection.
..
..
 
Thanks Bill for your sincere help. I will go through the code and also
visit the link; and try to understand VBA. Just to let you know that I
don't have any experience with VBA. Surely I shall require your help. Will
come back soon.

Dr. Anis Karim
 
Dr. Karim,

If you are just beginning to tackle VBA, you might want to start with my
book: Powerful PowerPoint for Educators. It is well below the skill
level of many of the VBA pros in this newsgroup, but it might be perfect
for you. You can get information about it at my Web site:

http://www.loyola.edu/education/PowerfulPowerPoint/

Let me know if you have any questions.

--David

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

I went through the code. It's nice! Well, I shall tell you what I
understood. Correct the wrong ones and answer my queries:

First, the visibility of the button in the slide master of the active
presentation is set to FALSE.
Then in the 'For' loop, all the available presentations are checked for the
name 'My Pres.PPT'.
If Presentation(X) is "My Pres.PPT', visibility of the button is set to
'TRUE'.
All the loops are closed.

Ok? Now, Just some doubts to be cleared...

(1) What is 'Option Explicit' ?

(2) 'The name of the shape on the master slide' means 'filename'? Also,
what is the 'index number' ?

(3) Why is 'mso' added before 'True' and 'False' ?

(4) What does this do?

With SlideShowWindows(1).View
.GotoSlide (.CurrentShowPosition)
End With

(5) Is there a way to run this code automatically when the presentation is
run?

(6) Is the code to be added to all slides of all presentations or just the
first slide of all presentations?

(7) I want the button to be visible in more than 1 presentation. So how
will I add that functionality to the code?

Still more questions to come. Just the doubts of a VBA beginner, that's
all. Anyway, thanks a lot for your sincere help. Awaiting your reply.

Dr. Anis Karim
 
Answers are in-line.


First, the visibility of the button in the slide master of the active presentation is set to FALSE.
Then in the 'For' loop, all the available presentations are checked for the name 'My Pres.PPT'.
If Presentation(X) is "My Pres.PPT', visibility of the button is set to 'TRUE'.
All the loops are closed.

This is done so that if any of the presentations that are open are a match,
the button will show, not just the last presentation checked.



(1) What is 'Option Explicit' ?
This statement tells the computer that all variables must be properly
declared prior to use. It helps to limit the number of coding/typing
mistakes and better utilizes the computer's memory.
(2) 'The name of the shape on the master slide' means 'filename'? Also,
what is the 'index number' ?
Name of the shape on the master Slide is probably 'CommandButton1', but may
be different if you have multiple command buttons in place. I use PPTools
add-in to find the name of a shape, but you can also use code to do the
same.
**PPTools -

http://www.rdpslides.com/pptools/
**Rename add-in -

http://www.mvps.org/skp/downloads/rename.zip
**Rename shapes code -

http://www.rdpslides.com/pptfaq/FAQ00584.htm

Each object on a slide is given a number based partially on when it was
added to the slide (this can change if the slide is duplicated). This is
the shape's 'Index number' on that slide.
(3) Why is 'mso' added before 'True' and 'False' ?
'mso' stands for Microsoft Office. It means the same thing as regular True
& False, just a convention within VBA.
(4) What does this do?
With SlideShowWindows(1).View
.GotoSlide (.CurrentShowPosition)
End With
Restarts the current slide in order to make the changes appear on the
current slide. Size, color, or placement modifications to shown objects
will be visible on active slides, objects that have not been drawn do not
get added.
(5) Is there a way to run this code automatically when the presentation is
run?
If you have an 'event capture' add-in loaded on the machine, yes. (Add-ins
beget add-ins, it seems) When the show opens (depending on which event
capture add-in was used) you can have this code automatically run whenever
the presentation is opened.
**Auto Events Add-in for PowerPoint 2000+
http://www.mvps.org/skp/downloads/autoevents.zip
**Event Generator 1.2
http://officeone.mvps.org/eventgen/eventgen.html

(6) Is the code to be added to all slides of all presentations or just the
first slide of all presentations?
The code can be added to the first slide of the presentation, or in a new
show-wide module. I would recommend the later since if it was slide based,
than deleting the slide would delete the code as well.


(7) I want the button to be visible in more than 1 presentation. So how
will I add that functionality to the code?
Replace this line --

If Presentations(1).Name = "My Pres.PPT" Then
With --

If Presentations(1).Name = "My Pres.PPT" or _

Presentations(1).Name = "My Pres2.PPT" or _

Presentations(1).Name = "My Pres3.PPT" Then

Now if any of the filenames (My Pres, My Pres2, or My Pres3) referred to
this presentation, it will activate the command button's visibility.




Still more questions to come. Just the doubts of a VBA beginner, that's
all. Anyway, thanks a lot for your sincere help. Awaiting your reply.
VBA is a little scary at first, don't let it throw you. VBA is powerful
stuff, but it is tamable and trainable. It can be a real work saver, if you
spend the time to learn it well.



Please read a few articles written for people venturing into the scary and
wonderful world of VBA, like you. They will cover things in better detail
than I was able to here.

**How do I USE this VBA stuff in PowerPoint?
http://www.rdpslides.com/pptfaq/FAQ00033.htm

**Where can I learn more about VBA programming in PowerPoint?
http://www.rdpslides.com/pptfaq/FAQ00032.htm

There are also dozens more available for the Googling.



Hope this helps give you a leg up on this.


--
Bill Dilworth, Microsoft PPT MVP
===============
Please spend a few minutes checking vestprog2@
out www.pptfaq.com This link will yahoo.
answer most of our questions, before com
you think to ask them.



Change org to com to defuse anti-spam,
ant-virus, anti-nuisance misdirection.
..
..
 
Thanks very much, Bill. Your help is indeed taking me closer to my goal.
Now, few more queries...

(1) Shouldn't the 'Presentations(1)' in the following line of the code be
replaced by 'Presentations(X)', since we are checking all presentations from
1 to Presentations.Count ?

If Presentations(1).Name = "My Pres.PPT" Then
.Visible = msoTrue

(2) How can we add the code to a Show-wide module?

(3) I would like to give my presentations to my colleagues and customers.
So, how can the code run automatically when the presentation is run, on
their machines with no 'event capture' add-in installed?

As always, awaiting your reply.

Dr. Anis Karim
 
Answers In-line:
(1) Shouldn't the 'Presentations(1)' in the following line of the code be
replaced by 'Presentations(X)', since we are checking all presentations from
1 to Presentations.Count ? Yes

(2) How can we add the code to a Show-wide module?
In VBE window select presentation name | Insert | Module
(3) I would like to give my presentations to my colleagues and customers.
So, how can the code run automatically when the presentation is run, on
their machines with no 'event capture' add-in installed?
You may be best off adding a continue button (on a slide with no click to
advance) . You also can not force your code to run on their machine. If
they have macro security set to high, it will not run.



If you need further assistance, please don't hesitate to post back. This
forum is an excellent source of problem solving information, but please also
spend some time researching the pptfaq and vba sources on-line. It sounds
like you will make an excellent coder, you may want to invest in some coding
classes, as well.

Sorry to rush, but I have projects that are due.
Bill D.
 
(3) I would like to give my presentations to my colleagues and customers.
So, how can the code run automatically when the presentation is run, on
their machines with no 'event capture' add-in installed?

Not possible, I'm afraid.

--
Steve Rindsberg, PPT MVP
PPT FAQ: www.pptfaq.com
PPTools: www.pptools.com
================================================
Featured Presenter, PowerPoint Live 2004
October 10-13, San Diego, CA www.PowerPointLive.com
================================================
 
Back
Top