I am newbie in using VBA I suppose that I want to automate export data from outlook mail and import to excel file xlsx as I searched for a tutorial for this and I find this tutorial https://www.exceltrainingvideos.com/get-data-from-outlook-into-excel-worksheet/ I followed these steps by creating a module as I inserted in this Module this code
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("SSV")
i = 1
For Each OutlookMail In Folder.Items
If OutlookMail.ReceivedTime >= Range("Email_Receipt_Date").Value And
Date <= 30 / apr / 2019 Then
Range("email_Subject").Offset(i, 0) = 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
Range("email_Body").Offset(i, 0).Value = OutlookMail.Body
Range("email_Body").Offset(i, 0).Columns.AutoFit
Range("email_Body").Offset(i, 0).VerticalAlignment = xlTop
i = i + 1
End If
Next OutlookMail
Set Folder = Nothing
Set OutlookNamespace = Nothing
Set OutlookApp = Nothing
End Sub
and finally when I am trying to run it I found this error
Run-error '1004' Method 'Range' of object '_Global) failed
It may be the error in excel file I have?
Date <= 30 / apr / 2019
won't do what you think. – Vincent G