slide count using vba

M

Mike

Hi, I'm trying to enter "Slide 1 of 10" (similar to Word and XL and PP in
edit mode) in the master slide footer so when I add or delete slides I don't
have to manually change the slide count. Can someone provide the code and/or
a pointer to an overview of the object model to code this? I want to be able
to distribute this as a single .ppt file so I think that eliminates use of
an add-in.

Many thanks,
Mike
 
M

Michael Koerner

This should help.
Slide numbering - Slide XX of YY
http://www.rdpslides.com/pptfaq/FAQ00548.htm



--
<>Please post all follow-up questions/replies to the newsgroup<>
<><>Email unless specifically requested will not be opened<><>
<><><>Do Provide The Version Of PowerPoint You Are Using<><><>
<><><>Do Not Post Attachments In This Newsgroup<><><>
Michael Koerner [MS PPT MVP]


"Mike" <meatmeinnovationsdotcom> wrote in message
Hi, I'm trying to enter "Slide 1 of 10" (similar to Word and XL and PP in
edit mode) in the master slide footer so when I add or delete slides I don't
have to manually change the slide count. Can someone provide the code and/or
a pointer to an overview of the object model to code this? I want to be able
to distribute this as a single .ppt file so I think that eliminates use of
an add-in.

Many thanks,
Mike
 
D

David M. Marcovitz

If you make it an addin, then everyone will have to install the addin.
Because you are using VBA, it will only work if people are running it
from the full version of PowerPoint (not the Viewer) and have macro
security at Medium or Low. Additionally, if it is not an addin, I don't
think you can have it run automatically. That is, the page numbers won't
get updated until the user does something (like hits a button).

To get the total number of slides, you need
ActivePresentation.Slides.Count. To get the current slide, you need
ActivePresentation.SlideShowWindow.View.Slide.SlideIndex.

--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.loyola.edu/education/PowerfulPowerPoint/
 
E

Echo S

Mike said:
Hi, I'm trying to enter "Slide 1 of 10" (similar to Word and XL and PP in
edit mode) in the master slide footer so when I add or delete slides I don't
have to manually change the slide count. Can someone provide the code and/or
a pointer to an overview of the object model to code this? I want to be able
to distribute this as a single .ppt file so I think that eliminates use of
an add-in.

You should be able to use Bill D's add-in for this
http://billdilworth.mvps.org/PageXXofYY.htm It adds the XX of YY when you
create the presentation; it shouldn't have to be available when you show the
presentation.
 
S

Steve Rindsberg

Hi, I'm trying to enter "Slide 1 of 10" (similar to Word and XL and PP in
edit mode) in the master slide footer so when I add or delete slides I don't
have to manually change the slide count. Can someone provide the code and/or
a pointer to an overview of the object model to code this? I want to be able
to distribute this as a single .ppt file so I think that eliminates use of
an add-in.

The end user would then have to do Tools, Macros, Macro, choose the correct
macro and then run it. Unless that's acceptable, distributing code in a PPT
file is a dead end.
 
M

me

Thanks David, that gets me part of what I need. This is my first dabbling
with vba and I don't understand the object model and don't know a good place
to get a quick overview. Where does the code go - autoopen, other? What
would be most helpful is to provide a .ppt file with a couple slides with
the code so I could just step through to see how it works. A pointer to a
good ref with examples would also be great.

Thanks!
mike.eddy
at
boeing.com
 
M

me

Isn't the same procedure used to create a VBA module only you don't package
it in a DLL? Can someone provide the code or, better yet, a sample file with
code in it for that? If not a sample file, how about good references to
sample code that demonstrates the PP doc obj model?

Many thanks,
Mike
Echo S said:
Whoops. Ignore my suggestion below. I didn't read your question closely
enough.

--
Echo [MS PPT MVP]
http://www.echosvoice.com


Echo S said:
You should be able to use Bill D's add-in for this
http://billdilworth.mvps.org/PageXXofYY.htm It adds the XX of YY when you
create the presentation; it shouldn't have to be available when you show the
presentation.
 
M

me

Can you put it in Auto_Open (is this start show? if not, what is, some sort
of click event?)? How can the guy who packaged it up in an add-in do it?
Isn't it the same code packaged differently?

Thanks,
Mike
 
D

David M. Marcovitz

The auto-open thing is going to be the tough part because it either has
to be an add-in that is already installed on the target computer, or the
user has to do something to run the macro (click a button or run the
macro through Tools > Macros).

For more information on VBA in PowerPoint, visit the Programming
PowerPoint section of the PowerPoint FAQ:

http://www.rdpslides.com/pptfaq/#PROGRAMMING_POWERPOINT

--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.loyola.edu/education/PowerfulPowerPoint/
 
S

Steve Rindsberg

Can you put it in Auto_Open (is this start show?

Afraid not. Auto_Open only fires when an add-in loads, not when a PPS (show)
or PPT (presentation) opens.

In a show you can sort of force the issue by opening with a slide that has a
"Click to start" sort of button on it. That can trigger a macro that loads
event handlers and such, but that's not particularly reliable, and it sounds
like it's not relevant either, given that you need to trigger events in edit
mode.
How can the guy who packaged it up in an add-in do it?
Isn't it the same code packaged differently?

Yes, but in that difference lies all the difference, you might say. ;-)

Note that it you distribute an addin, it'll work with ALL PPT files you edit,
not just ones that contain your code.
 
M

me

Thanks for the info, but I still think VBA is my best bet (given my limited
understanding). There are 300+ people to whom I need to distribute the show.
Many are non-technically savvy execs who either don't know how to load an
add-in or don't want to take the time. Clicking a particular place on the
first slide is waaaay easier. Double bonus if you can override keypress and
click on the first slide so it's completely transparent. I have no known
need to trigger events in edit mode. Can you help?

I'll never understand why they didn't build this in. It seems so obvious
that you want to know how long the slideshow is, especially when it's build
in to Word and XL. Nothing like being in an all week briefing and seeing
slide 114. You think it has to be over soon, but there are 350...

Many thanks!
Mike
 
S

Steve Rindsberg

Thanks for the info, but I still think VBA is my best bet (given my limited
understanding). There are 300+ people to whom I need to distribute the show.
Many are non-technically savvy execs who either don't know how to load an
add-in or don't want to take the time. Clicking a particular place on the
first slide is waaaay easier. Double bonus if you can override keypress and
click on the first slide so it's completely transparent. I have no known
need to trigger events in edit mode. Can you help?

If the presentation's set to Kiosk mode, keypresses won't work. They'll have
to navigate via mouse. But that'll apply to the entire presentation ... dunno
if that works for you or not.

Assuming Kiosk mode, your first slide could be a slide converted to bitmap
image so wherever they click, it's clicking the bitmap. That'd have the macro
assigned to it.

The macro itself could do something like:

Visit each slide in the current presentation
Look for a shape named "MyPageNumber" and if found, delete it (to remove old
ones if they're there)
Add a text box
Name it "MyPageNumber"
Set the text to "Slide " & current slide's ID & " of " &
activepresentation.slides.count
Format and position to taste

and finally, move to the next slide

But first, let's be certain Kiosk mode's ok

I'll never understand why they didn't build this in. It seems so obvious
that you want to know how long the slideshow is, especially when it's build
in to Word and XL. Nothing like being in an all week briefing and seeing
slide 114. You think it has to be over soon, but there are 350...

I think the same people program this part and also the progress gauges in MS
installs. The ones that go from 0 to 100%. Twenty or thirty times. With no
clue as to how many times you get to watch it.
 

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