The other systems are having the same files at the same location.

On windows 7 it is running but no error is getting displayed but it is not updating the sheet also.

On windows XP, it is showing an error on the line "Function CheckText(CellToCheck As Range, KeyString As String) As Boolean" as some Type error.

I am attaching the script for reference.

VB Code:
  1. Function CheckText(CellToCheck As Range, KeyString As String) As Boolean
  2.     Dim CheckRange As Range, Hit As Range
  3.     Set Hit = CellToCheck.Find(what:=KeyString, LookIn:=xlValues, Lookat:=xlWhole, MatchCase:=False)
  4.     CheckText = Not (Hit Is Nothing)
  5. End Function
  6.  
  7. Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
  8. Dim CheckRange As Range
  9. Dim KeyString As String
  10. vID = Split(EntryIDCollection, ",")
  11. Set XLApp1 = CreateObject("Excel.Application")
  12. Set CheckRange = XLApp1.Workbooks.Open("C:\Users\vijaywp\Desktop\India-IR-Schedule.xlsx").Sheets("Client Testing").Range("A1:S100")
  13. For i = 0 To UBound(vID)
  14. Set objMail = Application.Session.GetItemFromID(vID(i))
  15. vSubject = objMail.Subject
  16. vBody = objMail.Body
  17. vFrom = objMail.SenderEmailAddress
  18. VRtime = objMail.SentOn
  19. KeyString = Mid(Trim(Mid(vSubject, InStr(vSubject, "#") + 1)), 1, 3)
  20. If CheckText(CheckRange, KeyString) = True Then
  21.  
  22.    Set XLApp = CreateObject("Excel.Application")
  23.    Set xlWB = XLApp.Workbooks.Open("C:\Users\vijaywp\Desktop\sample.xlsx")
  24.    Set xlSheet = xlWB.Sheets("Sheet1")
  25.    vRow = xlSheet.Range("A" & XLApp.Rows.Count).End(-4162).Offset(1, 0).Row
  26.    xlSheet.Range("A" & vRow).Value = vSubject
  27.    xlSheet.Range("B" & vRow).Value = vBody
  28.    xlSheet.Range("C" & vRow).Value = VRtime
  29.    xlWB.Save
  30.    XLApp.Quit
  31.    Set objMail = Nothing
  32.    Set XLApp = Nothing
  33.  
  34. End If
  35. Next i
  36. XLApp1.DisplayAlerts = False
  37. XLApp1.Quit
  38. XLApp1.DisplayAlerts = True
  39. Set XLApp1 = Nothing
  40. End Sub

Please help me with this one.