freshpoet
09-07-2018, 11:25 AM
Hi All,
Im looping through some folders in outlook but once the code does about 5 loops I get a run time error: '430' Class does not support Automation or does not support expected interface at line code:
If CDate(OutlookMail.ReceivedTime) >= Range("Start_of_Month").Value Then
For intCount = 1 To 16
Set Folder = Nothing
Set OutlookNamespace = Nothing
Set OutlookApp = Nothing
Set OutlookApp = New Outlook.Application
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set Folder = OutlookNamespace.Folders("croesus support").Folders("Boîte de réception").Folders(intCount)
For Each OutlookMail In Folder.Items
If TypeName(OutlookMail) = "MailItem" Then
If CDate(OutlookMail.ReceivedTime) >= Range("Start_of_Month").Value Then
If CDate(OutlookMail.ReceivedTime) <= Range("End_of_Month").Value Then
Incoming = Incoming + 1
Range("Email_Sender").Offset(i, 0) = OutlookMail.ReceivedTime
Range("Email_Sender").Offset(i, 0).Columns.AutoFit
Range("Email_Sender").Offset(i, 0).VerticalAlignment = xlTop
i = i + 1
End If
End If
End If
Next OutlookMail
Range("Email_Sender").Offset(i, 0) = "End Of Inbox"
Range("Email_Sender").Offset(i, 0).Columns.AutoFit
Range("Email_Sender").Offset(i, 0).VerticalAlignment = xlTop
Range("Email_Date").Offset(i, 0) = "End Of Inbox"
Range("Email_Date").Offset(i, 0).Columns.AutoFit
Range("Email_Date").Offset(i, 0).VerticalAlignment = xlTop
Range("Recipient").Offset(i, 0) = "End Of Inbox"
Range("Recipient").Offset(i, 0).Columns.AutoFit
Range("Recipient").Offset(i, 0).VerticalAlignment = xlTop
Range("Email_Status").Offset(i, 0) = "End Of Inbox"
Range("Email_Status").Offset(i, 0).Columns.AutoFit
Range("Email_Status").Offset(i, 0).VerticalAlignment = xlTop
Range("Total").Offset(i, 0) = "End Of Inbox"
Range("Total").Offset(i, 0).Columns.AutoFit
Range("Total").Offset(i, 0).VerticalAlignment = xlTop
Next intCount
End Sub
Im looping through some folders in outlook but once the code does about 5 loops I get a run time error: '430' Class does not support Automation or does not support expected interface at line code:
If CDate(OutlookMail.ReceivedTime) >= Range("Start_of_Month").Value Then
For intCount = 1 To 16
Set Folder = Nothing
Set OutlookNamespace = Nothing
Set OutlookApp = Nothing
Set OutlookApp = New Outlook.Application
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
Set Folder = OutlookNamespace.Folders("croesus support").Folders("Boîte de réception").Folders(intCount)
For Each OutlookMail In Folder.Items
If TypeName(OutlookMail) = "MailItem" Then
If CDate(OutlookMail.ReceivedTime) >= Range("Start_of_Month").Value Then
If CDate(OutlookMail.ReceivedTime) <= Range("End_of_Month").Value Then
Incoming = Incoming + 1
Range("Email_Sender").Offset(i, 0) = OutlookMail.ReceivedTime
Range("Email_Sender").Offset(i, 0).Columns.AutoFit
Range("Email_Sender").Offset(i, 0).VerticalAlignment = xlTop
i = i + 1
End If
End If
End If
Next OutlookMail
Range("Email_Sender").Offset(i, 0) = "End Of Inbox"
Range("Email_Sender").Offset(i, 0).Columns.AutoFit
Range("Email_Sender").Offset(i, 0).VerticalAlignment = xlTop
Range("Email_Date").Offset(i, 0) = "End Of Inbox"
Range("Email_Date").Offset(i, 0).Columns.AutoFit
Range("Email_Date").Offset(i, 0).VerticalAlignment = xlTop
Range("Recipient").Offset(i, 0) = "End Of Inbox"
Range("Recipient").Offset(i, 0).Columns.AutoFit
Range("Recipient").Offset(i, 0).VerticalAlignment = xlTop
Range("Email_Status").Offset(i, 0) = "End Of Inbox"
Range("Email_Status").Offset(i, 0).Columns.AutoFit
Range("Email_Status").Offset(i, 0).VerticalAlignment = xlTop
Range("Total").Offset(i, 0) = "End Of Inbox"
Range("Total").Offset(i, 0).Columns.AutoFit
Range("Total").Offset(i, 0).VerticalAlignment = xlTop
Next intCount
End Sub