I have an Outlook macro that marks-as-read and moves all messages in a conversation into another folder. I assigned the macro to a button called "Archive". However, I cannot "undo" that action. If I
I end up un-deleting the message. I thought I would un-move the message. If I move a message by dragging and dropping it into another folder, undo works the way I expect. Here's the macro, does anyone know why this wouldn't support undo?
Sub ArchiveConversation()
Set ArchiveFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders("Archive")
Set Conversations = ActiveExplorer.Selection.GetSelection(Outlook.OlSelectionContents.olConversationHeaders)
For Each Header In Conversations
Set Items = Header.GetItems()
For i = 1 To Items.Count
Items(i).UnRead = False
Items(i).Move ArchiveFolder
Next i
Next Header
End Sub
Or do I have to code in undo support?
Unfortunately Outlook's undo functionality only operates on the user's actions, not on programmatic actions. Excel allows this via the Application.OnUndo
hook, but this isn't implemented in Outlook.
Maybe a reasonable alternative would be to create an 'Undo last archive' button; as long as you store the last archive action somewhere you can get to it, when the user clicks your 'undo' button then your macro manually moves the message back and marks it as unread (if it was originally that way).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With