How can I Automatically Update a Date Value in PPT using VBA

How can I make a powerpoint presentation automatically update a date value in a text box that is part of the Master Slide Format since I have it set to show up on every slide? I have been trying to figure this out for a few weeks on my own and feeling quite dumb.  I have written VBA code to get the date value I need, my issue is getting it to update each day with minimal user interaction. The presentation will run constantly on a dedicated computer with a full version of Powerpoint 2010. My last attempt was to try writing an event handler to run my macro (to update the date) each time slide 1 came around, however, it can't find my text box... I am just stumped and need help... I am not a programmer. As I like to say: I only know enough to be dangerous... ;-)  I will provide further example if required.  Thank you so much in advance, I need to figure this out soon.
 

Question Info


Last updated October 28, 2019 Views 11,930 Applies to:
Answer
Answer
Hi

If your message is in a normal text box on the master it should show on every slide. If it's a date placeholder then as Shyam says it wont update correctly.

Did your code originate with the 2003 macro recorder? A lot of it is not needed and code with selection or select cannot work in slide show mode.

This would probably do it but I don't see any evidence of an event handler to fire  it.

    Dim injdate As String
    Dim lastdate As String
    Dim injfree As Integer
    Dim BnrMsg As String
Sub UpdateBannerText()
   
    'This Macro defines the latest injury date
   
    injdate = InputBox("Please enter last injury date in this format:  mm/dd/yyyy")
    lastdate = injdate
    injfree = DateDiff("d", injdate, Now)
    BnrMsg = injfree & " Days Without An Injury"
    ActivePresentation.SlideMaster.Shapes("TextBox 7").TextFrame.TextRange = BnrMsg
       
End Sub
Sub ResetDate()

    'This Macro resets the date each day.
    'Note that UpdateBannerText Macro must have been run at least once since opening of presentation
    'for this  macro to work properly each additional day the presentation runs without interruption.
   
    injfree = DateDiff("d", lastdate, Now)
    BnrMsg = injfree & " Days Without An Injury"
    ActivePresentation.SlideMaster.Shapes("TextBox 7").TextFrame.TextRange = BnrMsg
End Sub






www.pptalchemy.co.uk

1 person was helped by this reply

·

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Answer
Answer

Hi,

Your code refers to TextBox 7 but the actual name of the shape on the slide master is Text Box 7. Note the space between text and box.

Regards
Shyam Pillai

http://skphub.com

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.