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.
..
..