How do I perform a calculation in a PowerPoint slideshow?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

For example - I would like to show days until a specific date or days since a
specific date, that recalculates whenever the slideshow is run.
 
You can only do this with vba

Here's example code that will give the difference in days between 01/01/2007
and now

Sub days_elapsed()
Dim dayselapsed As Integer
dayselapsed = DateDiff("d", #1/1/2007#, Now)
MsgBox dayselapsed & " days have elapsed"
End Sub
 
Hi D.Bell,

In addition to John's excellent advice, you will also need to force the user
to activate this macro/vba code. You could use an event trap, but these are
a bit advanced for most beginning coders. Let's use a simpler method.

On the first slide, insert a command button (from the toolbox toolbar).
Double click on it in edit view -- this will open the VBE that should say
something like ...

Private Sub CommandButton1_Click()

End Sub


Copy and paste John's code (with a small change), so it looks like ...

Private Sub CommandButton1_Click()
Dim dayselapsed As Integer
dayselapsed = DateDiff("d", #1/1/2007#, Now)
MsgBox dayselapsed & " days have elapsed"
SlideShowWindows(1).View.GotoSlide 2
End Sub


Close that window. Then set the text on the command button to "Click here
to continue" or some such, and change the transition settings to uncheck
advance on click and uncheck advance on time. This way the user will be
urged to push the command button that runs the code and tells them how long
it has been since they made those pesky New Years resolutions.

If you need any additional help with any of this, post back.


--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
vestprog2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
Back
Top