The attempted operation failed ... 2nd time running code

Status
Not open for further replies.

System Chaser

New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
I've written a macro that moves read receipts from shared inbox to a subfolder. The code works great when I run the code for the first time after opening outlook. If I attempt to run the macro/code a second time I get the following error:
Run-time error '-2147221233 (8004010f)':
The attempted operation failed. An object could not be found.

Any assistance or advice would be greatly appreciated and thank you for your time in advance.

Here is my code:

Sub Read_Receipts()
' ********************** Code to reference shared Inbox ***************************
Dim LogPath As String
Dim LogName As String

LogPath = "C:\Users\myaccount\Documents\"
LogName = "processlogfile.txt"
Dim FNum As Integer
Dim flogname As String
FNum = FreeFile()
flogname = LogPath & LogName
Open flogname For Append As FNum

Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim objsubFolder As Outlook.MAPIFolder
Dim DestFolder As Outlook.MAPIFolder
Dim aItem As Object

Print #FNum, Now() & " Name of Destination Folder Before Set Statement " & vbCrLf

Set objNS = GetNamespace("MAPI")
Set objFolder = objNS.Folders("PSC-Project")
Set objsubFolder = objFolder.Folders("Inbox")

Set DestFolder = objsubFolder.Folders("Status Update Receipts")
'*********The above line is where the error occurs when running the procedure for the 2nd time*************

' I've tried this line as well: Set DestFolder = objNS.Folders("PSC-Project").Folders("Inbox").Folders("Status Update Receipts")

' *****Code to move read receipts etc************


Set DestFolder = Nothing
Set objNS = Nothing
Set objFolder = Nothing
Set objsubFolder = Nothing
Set aItem = Nothing
Close #FNum
End Sub
 

System Chaser

New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Diane,


Set DestFolder = objsubFolder.Folders("Status Update Receipts")

Is the line that generates the error. This only occurs when I run the macro for a second time. The first time it works fine. This subfolder (Status Update Receipts) has the double blue arrow on it. Not sure if that makes a difference. The shared inbox does not have the double blue arrow on it.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
D Outlook 2016 Outlook Error Msg "The operation cannot be performed ..." How to Stop it Using Outlook 3
Cdub27 Your changes to this item couldn't be saved because Server Denied Operation (HTTP 403 Forbidden) Using Outlook 1
Diane Poremsky Could not complete the operation. One or more parameter values are not valid. New Slipstick.com Articles 0
M Very slow operation Using Outlook 0
Christiaan Could not complete operation because the service provider does not support it Using Outlook 2
Diane Poremsky This operation has been cancelled due to restrictions New Slipstick.com Articles 0
S Outlook 2010 I am getting error code 0x8DE00006 'the operation failed'. outlook 2010 send/receive progress Using Outlook.com accounts in Outlook 2
J An attempt operation failed. An object could not be found at line5. Outlook VBA and Custom Forms 2
H Outlook 2010, "The Operation Failed" Sending emails Using Outlook 4
S Microsoft office Cannot complete operation error Outlook VBA and Custom Forms 1
J New Outlook 2007 form - try to send and get error Operation Failed Outlook VBA and Custom Forms 11
S Outlook 2013. Adding office 365 email account causes 'The operation failed' Using Outlook 2
M Outlook 2010 Calendar error Operation Failed Using Outlook 6
S Unknown error and The operation failed Using Outlook 1
S The operation failed error while send email to other domain. Using Outlook 1
R "The Operation Failed. The messaging interfaces have returned an unknown error Exchange Server Administration 3
B Task List in To-Do Bar 'The operation failed. An object could not be found' Using Outlook 3
N Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)) Outlook VBA and Custom Forms 1
M Cannot Send - "Operation failed. An object cannot be found" BCM (Business Contact Manager) 4
D Outlook 2007: "the Operation Failed" on Send to Multiple addresses Using Outlook 6
L Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)) Outlook VBA and Custom Forms 1
J The operation failed. Outlook VBA and Custom Forms 17
W Save Operation Failed error Outlook VBA and Custom Forms 7
Mark Foley The upload of "Calendar" failed. There was a problem with the request. Using Outlook 6
P Mail delivery failed returning message to sender Using Outlook 1
F 'General failure (URL) Server execution failed' Using Outlook 1
Xueying run a script in rules, first time succeed, failed afterwards Outlook VBA and Custom Forms 3
wallisellener database creation failed BCM (Business Contact Manager) 0
R catalog Content Index failed-Unable to mount database.(hr=0x80004005,ec=-501) Exchange Server Administration 0
J Synchronization of some deletions failed [0-130] Exchange Server Administration 6
M Synchronization of some deletions failed [0-130] Using Outlook 3
P Sync Center appointments failed to synchronize Using Outlook 1
S COM Addin Failed to load in Outlook 2003 Outlook VBA and Custom Forms 1
S Failed to install Business Conctact Manager 2007 BCM (Business Contact Manager) 1
R RE: Business Contact manager failed to install BCM (Business Contact Manager) 1
A Creating Redemption.MAPIUtils failed with Windows 7 x64 Outlook VBA and Custom Forms 5
S Failed to create an RDO session instance: Class not registered Outlook VBA and Custom Forms 1
R SQL Server Setup failed - Please help?! BCM (Business Contact Manager) 2
H Failed install BCM (Business Contact Manager) 2
L Exchange Management Console - Initializtion failed on Logon Failure: unknown username or bad passwor Exchange Server Administration 4
P Setup failed to install Business Contact Manager for Outlook 2007 BCM (Business Contact Manager) 2
E Re:BCM failed to install in outlook 2007 due to SQL Server Express 20 BCM (Business Contact Manager) 1
T Re: Setup failed to install Business Contact Manager BCM (Business Contact Manager) 1
B Re: BCM failed to initialize the common language runtime BCM (Business Contact Manager) 4
E Connecting to database failed BCM (Business Contact Manager) 3

Similar threads

Top