+ Reply to Thread
Results 1 to 2 of 2

Script problem Error in Rule

Hybrid View

Shakey88 Script problem Error in Rule 09-18-2013, 04:49 AM
skatonni Re: Script problem Error in... 11-25-2013, 10:17 AM
  1. #1
    Registered User
    Join Date
    09-18-2013
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2007
    Posts
    2

    Unhappy Script problem Error in Rule

    Good Morning all,

    I've come begging for help,

    I have a number of outlook scripts which run on incoming emails which meet a set criteria... these seem to run perfect throughout the day, however occasionally when im out of the office at night some seem to fail...
    I dont have admin rights however i do have elevated privledges allowing me to ensure the hard-drive isnt turning off and the computer isnt going to sleep...

    I imagine its a problem with the way I have written the script... I would be very appreciative if someone could give me some pointers as to where I have gone wrong... its driving me nuts, because when every time i test the code it works fine...


    This one one of the Scripts failing, I have another one which is failing too...

    This one runs off a rule which checks emails as they arrive for a specific subject... it then downloads that emails attachment to C:\Temp ( i believe its failing here as there are no files in C:\temp when I check in the morning), checks if it has all the attachments required to execute the code if not it ends sub... once it has all 4 attachments in the temp folder it, opens an excel workbook and runs a macro in there (this is a pretty beefy macro which creates several reports & emails several distro lists)... It then writes a success or fail to a notepad

    
    Dim Garb As Variant
    Dim Sucfail As Variant
    
    ------------------------
    Sub MailhandlerPerStatYester(ThisMail As MailItem)
        Dim wbook As Workbook
        Dim objAtt As Outlook.Attachment
        Dim saveFolder As String
        On Error GoTo Ender
        Garb = "Outlook Kickoff Yesterdays Stats"
        saveFolder = "C:\Temp"
        For Each objAtt In ThisMail.Attachments
        
        objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
        
        Next
        
    If Dir("C:\Temp\Extract 1.xls") <> "" Then
    Else
    GoTo Endit
    Exit Sub
    End If
    If Dir("C:\Temp\Extract 2.xls") <> "" Then
    Else
    GoTo Endit
    Exit Sub
    End If
    If Dir("C:\Temp\Extract 3.xls") <> "" Then
    Else
    GoTo Endit
    Exit Sub
    End If
    If Dir("C:\Temp\Extract 4.xls") <> "" Then
    Else
    GoTo Endit
    Exit Sub
    End If
        
        
    
    Call OpenMacroBook
    
        Excel.Run ("PSY_Auto")
        Windows("MacroBook.xlsm").Close False
        Excel.Application.Quit
        Set objAtt = Nothing
        Sucfail = "Completed Successfully"
        Call WriteLog
    Exit Sub
    Ender:
    Sucfail = "Failed to Run"
    Call WriteLog
    Endit:
    Set objAtt = Nothing
    End Sub
    
    --------------------------
    Sub OpenMacroBook()
    
        Set wbook = Nothing
        On Error Resume Next
        Set wbook = Excel.Workbooks("MacroBook.xlsm")
        If wbook Is Nothing Then Excel.Workbooks.Open ("\\**-***-***\***_***_*** *** ***\***** Databases\Tools\MacroBook.xlsm")
        Excel.Application.Visible = True
        Excel.Windows("MacroBook.xlsm").Activate
    
    End Sub
    
    -------------------------------------------
    Sub WriteLog()
    Dim Log As Variant
    
    User = Environ$("Username")
    
    Log = "\\**-***-***\***_***_*** *** ***\***** Databases\Automation Log\Log.txt"
    fnum = FreeFile()
    
    Open Log For Append As fnum
    Write #fnum, Now() & " " & Garb & " " & Sucfail & " - By " & User
    Close #fnum
    Sucfail = Null
    Garb = Null
    End Sub
    Many Thanks
    Shakey

  2. #2
    Forum Contributor
    Join Date
    08-27-2006
    Posts
    136

    Re: Script problem Error in Rule

    Quote Originally Posted by Shakey88 View Post
    I have a number of outlook scripts which run on incoming emails which meet a set criteria... these seem to run perfect throughout the day, however occasionally when im out of the office at night some seem to fail...
    I dont have admin rights however i do have elevated privledges allowing me to ensure the hard-drive isnt turning off and the computer isnt going to sleep...

    I imagine its a problem with the way I have written the script... I would be very appreciative if someone could give me some pointers as to where I have gone wrong... its driving me nuts, because when every time i test the code it works fine...
    I do not think I have seen anyone successfully troubleshoot a Run a Script rule that sporadically breaks. Recreate the rule in ItemAdd or NewMailex. http://www.outlookcode.com/article.aspx?id=62

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem with isempty rule
    By Frozenice in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-11-2013, 02:41 PM
  2. [SOLVED] script to enable a rule
    By tiger10012 in forum Outlook Formatting & Functions
    Replies: 2
    Last Post: 02-11-2013, 10:14 AM
  3. Indirect validation rule error
    By toclare84 in forum Excel General
    Replies: 7
    Last Post: 10-06-2010, 05:18 AM
  4. [SOLVED] VB script error
    By Anthony in forum Excel General
    Replies: 4
    Last Post: 07-14-2005, 05:05 AM
  5. [SOLVED] VB Script error
    By Anthony in forum Excel General
    Replies: 2
    Last Post: 07-13-2005, 11:05 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1