VBA not running only on my system not running on any other system
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:
Function CheckText(CellToCheck As Range, KeyString As String) As Boolean
Dim CheckRange As Range, Hit As Range
Set Hit = CellToCheck.Find(what:=KeyString, LookIn:=xlValues, Lookat:=xlWhole, MatchCase:=False)
CheckText = Not (Hit Is Nothing)
End Function
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim CheckRange As Range
Dim KeyString As String
vID = Split(EntryIDCollection, ",")
Set XLApp1 = CreateObject("Excel.Application")
Set CheckRange = XLApp1.Workbooks.Open("C:\Users\vijaywp\Desktop\India-IR-Schedule.xlsx").Sheets("Client Testing").Range("A1:S100")
For i = 0 To UBound(vID)
Set objMail = Application.Session.GetItemFromID(vID(i))
vSubject = objMail.Subject
vBody = objMail.Body
vFrom = objMail.SenderEmailAddress
VRtime = objMail.SentOn
KeyString = Mid(Trim(Mid(vSubject, InStr(vSubject, "#") + 1)), 1, 3)
If CheckText(CheckRange, KeyString) = True Then
Set XLApp = CreateObject("Excel.Application")
Set xlWB = XLApp.Workbooks.Open("C:\Users\vijaywp\Desktop\sample.xlsx")
Set xlSheet = xlWB.Sheets("Sheet1")
vRow = xlSheet.Range("A" & XLApp.Rows.Count).End(-4162).Offset(1, 0).Row
xlSheet.Range("A" & vRow).Value = vSubject
xlSheet.Range("B" & vRow).Value = vBody
xlSheet.Range("C" & vRow).Value = VRtime
xlWB.Save
XLApp.Quit
Set objMail = Nothing
Set XLApp = Nothing
End If
Next i
XLApp1.DisplayAlerts = False
XLApp1.Quit
XLApp1.DisplayAlerts = True
Set XLApp1 = Nothing
End Sub
Please help me with this one.
Re: VBA not running only on my system not running on any other system
>>>as some Type error.
Can you do this? Add this one line
Code:
Msgbox CheckRange.Address & ", " & KeyString
before this line
Code:
If CheckText(CheckRange, KeyString) = True Then
What do you get?
1 Attachment(s)
Re: VBA not running only on my system not running on any other system
Hello KoolSid,
After running the script the way u told me I am getting something which I attached as a screenshot please have a look and let me know what to do.
It is displaying some code and then after it is displaying "FGP" which is the text taken from the mail subject.
And sorry the title of this post is that this VBA is running only on my system and not running on any other system.
Thanks.
Re: VBA not running only on my system not running on any other system
from your screenshot it would appear that your range and string are correct and no obvious type mismatch error
do you possibly have those names defined globally or at module level elsewhere?
Re: VBA not running only on my system not running on any other system
The names are not defined in any of the other modules.
It is working perfectly on my system but not on any other system.What can be the issue?
Re: VBA not running only on my system not running on any other system
Quote:
.What can be the issue?
different version of excel?
what result in koolsid's message box on other systems?