Results 1 to 6 of 6

Thread: VBA not running only on my system not running on any other system

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    41

    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:
    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.

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    41

    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.
    Attached Images Attached Images  
    Last edited by jobs123; Feb 14th, 2012 at 01:45 AM.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2012
    Posts
    41

    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?

  6. #6
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: VBA not running only on my system not running on any other system

    .What can be the issue?
    different version of excel?

    what result in koolsid's message box on other systems?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width