You will probably find that the line should be
Code:
ActiveDocument.Undo 1
or you will get an error message. You can also achieve the same thing, without Undo, by moving the start and end of the range.
There may also be a moire elegant way of extracting the name from the document, should you wish to share an example document.