Хорошо, я понял, что, вероятно, не рекомендуется, но у меня это сработало.Я добавил функцию спецэлементов, которая ищет пустые ячейки в столбце, а затем добавляет дату, которая мне нужна.Большое спасибо за помощь
Public Sub Driver()
Dim Item As MailItem, x%
Dim r As Object 'As Word.Range
Dim doc As Object 'As Word.Document
Dim xlApp As Object
Dim olItems As Outlook.Items
Dim sourceWB As Workbook
Dim sourceSH As Worksheet
Dim olFolder As Outlook.Folder
Dim strFile As String
Dim olEleColl As MSHTML.IHTMLElementCollection
Dim olNameSpace As Outlook.NameSpace
Dim olHTML As MSHTML.HTMLDocument: Set olHTML = New MSHTML.HTMLDocument
Dim OutlookApp As Object
Dim OutlookMail As Object
Dim objEmail As Outlook.MailItem
Dim intRowIndex As Integer
Dim intEmailIndex As Integer
Dim objFolder As Outlook.MAPIFolder
Set xlApp = CreateObject("Excel.Application")
With xlApp
.Visible = True
.EnableEvents = False
.EnableEvents = False
.DisplayAlerts = False
End With
Set olNameSpace = Application.GetNamespace("MAPI")
Set olFolder = olNameSpace.GetDefaultFolder(olFolderInbox)
Set olItems = olFolder.Items
'olItems.Sort ("[ReceivedTime]")
Set Item = olItems(olItems.Count)
'save Outlook email's html body (tables)
With olHTML
.Body.innerHTML = Item.HTMLBody
Set olEleColl = .getElementsByTagName("table")
End With
strFile = "C:\xls\Driver.xlsx"
Set sourceWB = Workbooks.Open(strFile, , False, , , , , , , True)
Set sourceSH = sourceWB.Worksheets("Sheet1")
sourceWB.Activate
cells.Select
Selection.Delete
For Each Item In Application.ActiveExplorer.Selection
Set doc = Item.GetInspector.WordEditor
For x = 1 To doc.tables.Count
Set r = doc.tables(x)
r.Range.Copy
sourceSH.Paste
ActiveSheet.Pictures.Delete
rows(4).Delete
rows(1).EntireRow.Delete
rows(1).EntireRow.Delete
rows(1).EntireRow.Delete
Range("D:E").Delete
sourceSH.cells(sourceSH.rows.Count, 1).End(3).Offset(1).Select
sourceSH.cells(2, 4) = Item.ReceivedTime
sourceSH.cells(1, 4) = "Received Time"
Range("D2").CurrentRegion.SpecialCells(xlCellTypeBlanks).Value = Item.ReceivedTime
Next
Next
End Sub