This code worked fine a month ago. Now it throws up the
error, operation failed, object could not be found, at
the line indicated by the ****'s
Folders haven't been moved, renamed, contaminated, etc.
Outlook 2000 SR-1.
Any ideas? This code is in a custom toolbar button but
it fails when run directly too. (Also, is this the usual
way to do this -- all it needs to do is move a message
to a special folder.)
Thanks in advance for any clues.
--
"Life is nothing if you're not obsessed." --John Waters
Sub MoveToCommentsFolder()
Dim OA As Application, NS As NameSpace, IBX As MAPIFolder
Dim msg As MailItem, PF As MAPIFolder, JM As MAPIFolder
Set OA = CreateObject("Outlook.Application")
Set NS = OA.GetNamespace("MAPI")
Set IBX = NS.GetDefaultFolder(olFolderInbox)
Set PF = IBX.Parent
Set JM = PF.Folders("JMARTIN 1230") ' **** FAILS HERE ****
On Error GoTo QuitIfError
If OA.ActiveWindow.Class = olExplorer Then
For Each msg In OA.ActiveExplorer.Selection
msg.Move (JM.Folders("Comments"))
Next msg
End If
If OA.ActiveWindow.Class = olInspector Then
OA.ActiveInspector.CurrentItem.Move (JM.Folders("Comments"))
End If
Exit Sub
QuitIfError:
MsgBox "Glitch: " & Err.Description
Set OA = Nothing
Set NS = Nothing
Set IBX = Nothing
Set PF = Nothing
Set msg = Nothing
End Sub