I'm trying to create a powerpoint presentation which will show the number of days since an injury in the workplace.
When the presentation is first opened by the user i'd like a macro to run that prompts for a date to be entered since the last injury. So far for that i have this which appears to work ok:-
Sub EveryDayAccidents()
Dim injdate As String
Dim lastdate As String
Dim injfree As Integer
Dim BnrMsg As String
'This Macro defines the latest injury date
injdate = InputBox("Please enter last injury date in this format: dd/mm/yyyy")
lastdate = injdate
injfree = DateDiff("d", injdate, Now)
BnrMsg = injfree
ActivePresentation.Slides(3).Shapes("Accidents").TextFrame.TextRange = BnrMsg
End Sub
What i'm missing is some code or another sub that will call this code when the presentation is opened.
Will the text box then update when the date changes naturally or will something need to be running in the background to update the text box? The plan is to leave the slides in the presentation running in a loop until an accident occurs then it would be reset and start again.
Any help would be much appreciated!!
EDIT
So now i have this:-
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
If SSW.View.CurrentShowPosition = 3 Then
injdate = ActivePresentation.Slides(3).Shapes("Accidents").TextFrame.TextRange
injfree = DateDiff("d", injdate, Now)
BnrMsg = injfree
ActivePresentation.Slides(3).Shapes("Accidents").TextFrame.TextRange = BnrMsg
End If
End Sub
Which does update the slide when the presentation is running... But it is treating the number in the text box as an actual date (65 turns into 05/03/1900) which means my date difference is in the region of 41,600... What i'd like to do is ignore the dates completely for a moment.
If i input a number (say 1) into the text box i would then want that number to increment by 1 each day, i think this code will do that anyway at the moment but i'm lacking the skills to convert :-
injfree = DateDiff("d", injdate, Now)
Into
injfree = injfree + 1 when date changes (garbage i know)
Please help :)