Option Explicit Private Const xlUp As Long = -4162 Sub CopyToExcel(olItem As Outlook.MailItem) Dim xlApp As Object Dim xlWB As Object Dim xlSheet As Object Dim vText, vText2, vText3, vText4, vText5 As Variant Dim sText As String Dim rCount As Long Dim bXStarted As Boolean Dim enviro As String Dim strPath As String enviro = CStr(Environ("USERPROFILE")) 'the path of the workbook strPath = enviro & "\Documents\test.xlsx" On Error Resume Next Set xlApp = GetObject(, "Excel.Application") If Err <> 0 Then Application.StatusBar = "Please wait while Excel source is opened ... " Set xlApp = CreateObject("Excel.Application") bXStarted = True End If On Error GoTo 0 'Open the workbook to input the data Set xlWB = xlApp.Workbooks.Open(strPath) Set xlSheet = xlWB.Sheets("Sheet1") 'Find the next empty line of the worksheet rCount = xlSheet.Range("B" & xlSheet.Rows.Count).End(xlUp).Row rCount = rCount + 1 sText = olItem.Body xlSheet.Range("B" & rCount) = .subject xlSheet.Range("c" & rCount) = .receivedtime xlSheet.Range("d" & rCount) = .body 'xlSheet.Range("e" & rCount) = vText4 'xlSheet.Range("f" & rCount) = vText5 xlWB.Close 1 If bXStarted Then xlApp.Quit End If Set xlApp = Nothing Set xlWB = Nothing Set xlSheet = Nothing End Sub