(Solved) – Run-time 1004 – Method ‘Range’ of object ‘_Global’ failed

(solved)-–-run-time-1004-–-method-‘range’-of-object-‘-global’-failed

Can someone assist with this runtime error please?

Sub getDataFromOutlook()
Dim OutlookApp As Outlook.Application
Dim OutlookNamespace As Namespace
Dim Folder As MAPIFolder
Dim OutlookMail As Variant
Dim i As Integer

Set OutlookApp = New Outlook.Application

Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")

Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox).Folders("test")

i = 1

For Each OutlookMail In Folder.Items


    **If OutlookMail.ReceivedTime >= Range(“email_Receipt_Date”).Value Then**   (This is the error)
        Range(“email_Subject”).Offset(i, 0).Value = OutlookMail.Subject
        Range(“email_Subject”).Offset(i, 0).Columns.AutoFit
        Range(“email_Subject”).Offset(i, 0).VerticalAlignment = xlTop
        Range(“email_Date”).Offset(i, 0).Value = OutlookMail.ReceivedTime
        Range(“email_Date”).Offset(i, 0).Columns.AutoFit
        Range(“email_Date”).Offset(i, 0).VerticalAlignment = xlTop
        Range(“email_Sender”).Offset(i, 0).Value = OutlookMail.SenderName
        Range(“email_Sender”).Offset(i, 0).Columns.AutoFit
        Range(“email_Sender”).Offset(i, 0).VerticalAlignment = xlTop

        i = i   1
    End If
    Next OutlookMail

    Set Folder = Nothing
    Set OutlookNamespace = Nothing
    Set OutlookApp = Nothing

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *