I have VBA code which processes many slides in a PowerPoint file. Part of the code temporarily resizes the slides so I can export images in a different aspect ratio.
I cannot resize them back again because PowerPoint never puts their contents back exactly the way it was before the resize, and so I execute
Application.StartNewUndoEntry
before I do the resize, and then
Application.CommandBars.ExecuteMso "Undo"
after I export to undo the resize and ensure things all go back exactly the way they were before the resize.
I then write some metadata to the slides notes page and repeat for the next slide.
The problem is that
Application.CommandBars.ExecuteMso "Undo"
is not blocking until the undo completes. This means the writing to the notes page (which is after then Application.CommandBars.ExecuteMso "Undo") gets undone also!
How can I get PowerPoint to wait until it has finished Application.CommandBars.ExecuteMso "Undo" before executing the code that writes to the notes page?
I have tried putting in a wait and a sleep of up to a couple of seconds even, between the undo and my other code, but it seems this doesn't help at all. It still undos trhe code I execute AFTER the call to executeMso "Undo"
(I have also thought of storing the ids of the slides i need ot update the notes pages with until aftger all the resizing and exporting is finished, and then going an updateing all the notes pages, but I suspect that would be a waste of time ebcasue the first one (or more) will still get lost due to the last undo not finishing its work.)
(I have also tried moving the notes updating code to before I resize (and then undo) the slide - but this doesn't work because it just moves the problem to the previous slide undo not finishing, rather than the current one.)