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
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