I have a pretty simple VBA bit in Word 2003 that changes the font of the document to "eco-font" (long story) and brings up the Print dialog box.
When the user clicks “Cancel” or “OK”, the code performs “cancel” to return the change.
The problem is that sometimes, when I click "OK" to print the document, it is necessary to undo two actions ("change the font" and "update field"). I can not predict when this will happen.
Is there a way to read the last item in the Word undo buffer? That way, I can simply continue to undo until the font change is complete.
Edit:
Final code (cut down):
ActiveDocument.Range.Bookmarks.Add ("_tempEcoUndoStart_")
ActiveDocument.Content.Font.Name = "Nanonymus Eco Sans"
Dialogs(wdDialogFilePrint).Show
While ActiveDocument.Bookmarks.Exists("_tempEcoUndoStart_")
ActiveDocument.Undo
Wend
source
share