How do I eliminate the "Enable Macro" selection?
I made all the changes Michel, thanks a lot.
Actually I think the slow speed is in part because of the way I invoke the
macro.
I select on item then invoke the macro by pressing my macro button, then I
repeat for the next item, etc.
A better method would be to select multiple items first and then invoke the
macro once to move the multiple selected items at once.
For completeness, here is my final code:
Sub MoveToTrash()
On Error Resume Next
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Dim objItem As MailItem
Dim Sel As Outlook.Selection
' "Trash" folder in user namespace
Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.Folders("KJB").Folders("Trash")
' Warn if "Trash" folder doesnt exist
If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If
' User selected emails to move to trash
Set Sel = Application.ActiveExplorer.Selection
' For each mail item in user selection, move it to "Trash" folder
For Each objItem In Sel
objItem.UnRead = False
objItem.Move objFolder
Next
End Sub
|