M
mobamoba
I use Outlook 2007 on a single computer (i.e. not Exchange) and have
been using a VB macro for years without a problem. I rebooted today,
restarted Outlook and the macro is no longer working. Nothing in my
setup has changed at all. When I go to the VB Editor, the error I'm
getting is "Object not found." Considering I've changed absolutely
nothing, what, suddenly, isn't being found? I've posted the code
below - it's really a very simplistic macro designed to move email and
meeting requests from my inbox to a folder called Saved Mail. Thanks
in advance for any help because this problem is making me nuts!
Sub MoveMessage()
Dim onsMapi As Outlook.NameSpace
Dim oexpSource As Outlook.Explorer
Dim objItem As Object
Dim omapiDestination As Outlook.MAPIFolder
Dim lCount As Long
' Find the destination Folder 'Saved Mail'
Set onsMapi = Application.GetNamespace("MAPI")
Set omapiDestination = onsMapi.Folders.GetFirst.Folders("Saved
Mail")
' Get the current explorer
Set oexpSource = Application.ActiveExplorer
' Check each selection
For Each objItem In oexpSource.Selection
If TypeOf objItem Is Outlook.MailItem Or TypeOf objItem Is
Outlook.MeetingItem Then
' Move selection
objItem.Move omapiDestination
End If
Next
' Clean up
Set omapiDestination = Nothing
Set oexpSource = Nothing
Set onsMapi = Nothing
Set objItem = Nothing
End Sub
been using a VB macro for years without a problem. I rebooted today,
restarted Outlook and the macro is no longer working. Nothing in my
setup has changed at all. When I go to the VB Editor, the error I'm
getting is "Object not found." Considering I've changed absolutely
nothing, what, suddenly, isn't being found? I've posted the code
below - it's really a very simplistic macro designed to move email and
meeting requests from my inbox to a folder called Saved Mail. Thanks
in advance for any help because this problem is making me nuts!
Sub MoveMessage()
Dim onsMapi As Outlook.NameSpace
Dim oexpSource As Outlook.Explorer
Dim objItem As Object
Dim omapiDestination As Outlook.MAPIFolder
Dim lCount As Long
' Find the destination Folder 'Saved Mail'
Set onsMapi = Application.GetNamespace("MAPI")
Set omapiDestination = onsMapi.Folders.GetFirst.Folders("Saved
Mail")
' Get the current explorer
Set oexpSource = Application.ActiveExplorer
' Check each selection
For Each objItem In oexpSource.Selection
If TypeOf objItem Is Outlook.MailItem Or TypeOf objItem Is
Outlook.MeetingItem Then
' Move selection
objItem.Move omapiDestination
End If
Next
' Clean up
Set omapiDestination = Nothing
Set oexpSource = Nothing
Set onsMapi = Nothing
Set objItem = Nothing
End Sub