How to update all date/time values in a PowerPoint slide (VBA)
I'm writing a PPT add-in that makes a PNG of a slide and uploads it somewhere. I want the slide creator to be able to add dates/times in text boxes (using Insert > Date & Time), and have those dates/times reflect the time the snapshot is taken.
If one checks "Update Automatically" when adding them, the timestamps only update when the slide 开发者_如何学运维is opened. Is there a way to find all the date/time tags/fields in all shapes and force them to update immediately before I take the snapshot?
The only other way I've found to possibly do what I want is to have "named" shapes on the slide that are empty and populate a date into them programmatically...but this introduces extra complexity for the person building the slide and is generally messier. But I'm open to other possibilities if any.
Thanks!
-EDIT-
Ok, I just realized that when I create the PNG with SaveGraphic the timestamps in the PNG are updated! So that probably is all I absolutely need. Interestingly though, the datestamps in what the user is looking at on-screen don't get updated, which is potentially confusing to the user. So the question still stands...seems like this should be doable.
Well, the bad news is you can't. The field (either as a Footer or input from e.g. TextRange.InsertAfter.InsertDateTime DateTimeFormat:=ppDateTimeMMddyyhmmAMPM, InsertAsField:=msoTrue
) works like this:
The DateTime will update when you run the slide deck only in the slide show window. When you exit that slide show window, you will see the earlier date/time of when the field was either inserted or or the presentation was opened. The field updates in the editing windows when the presentation is opened or inserted the first time.
There are only two ways to handle a situation like this:
- Force a close/reopen of your PowerPoint deck (which is an awful solution, but I had to mention it).
- Don't use the DateTime field the way
you have been. What I mean by this is
to control the date/time manually.
You can still use Insert Date/Time,
but manage the text boxes where it is
inserted so that you remove what is
in that text box and repopulate it
with a new
.InsertDateTime
each time you need it, such as before theSlide.Export
you are doing.
精彩评论