Results 1 to 5 of 5

On error goto

Threaded View

  1. #1
    Registered User
    Join Date
    01-19-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    On error goto

    Hi,

    I am trying to create a macro that runs a path if it is present, if not it will try the next down down in a list, and so on until it shows an error message if nothing is found. An extract of the code is beneath, but the second on error goto wont work, it just says "File not found" and stops. However the first one works just fine. I am sure that there is a far cleaner way of doing this, but I'm darned if I know it. Any help would be greatly appreciated as I have been mucking about with it for hours.


    Private Sub runTxShuttleScript(scriptName As String, xlFile As String, sheetName As String, startRow As String, numRows As String, Optional logColumn As String)
    
            On Error GoTo newshuttle
            programm = "c:\program files\winshuttle\txshuttle\txshuttle.exe"
            out = Shell(programm & " " & scriptName & xlFile & sheetName & startRow & numRows & logColumn, vbNormalFocus)
    
    exithandler:
            Exit Sub
            
    newshuttle:
           On Error GoTo newshuttle2
           programm = "C:\Program Files\Winshuttle\transactionSHUTTLE8\txshuttle.exe"
           out = Shell(programm & " " & scriptName & xlFile & sheetName & startRow & numRows & logColumn, vbNormalFocus)
            
    exithandler2:
            Exit Sub
    
    newshuttle2:
            On Error GoTo errhandler
            programm = "c:\program files\winshuttle\runshuttle8\txrunner.exe"
            out = Shell(programm & " " & scriptName & xlFile & sheetName & startRow & numRows & logColumn, vbNormalFocus)
            
    exithandler3:
            Exit Sub
    
    
    errhandler:
            MsgBox "This operation can only be run on a computer with XXXXX." & vbNewLine & "You do not have the correct software.", _
            vbOKOnly, "No Software Found"
            Sheets("Master").Select
            
    End Sub
    Last edited by tostle; 01-19-2010 at 01:19 PM. Reason: add code tags

Thread Information

Users Browsing this Thread

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

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