Results 1 to 2 of 2

Run 2nd sub procedure when the first is done successful

Threaded View

  1. #1
    Registered User
    Join Date
    11-05-2009
    Location
    NL
    MS-Off Ver
    Excel 2007
    Posts
    54

    Run 2nd sub procedure when the first is done successful

    Hello,

    With VBA I load a batch script. Then I run a 2nd procedure in VBA. The 2nd procedure should only run if the batch script is closed.

    Sub BatchFile()
        Dim RetVal
        RetVal = Shell("C:\Batch.bat", vbHide)
    End Sub
    I found the following somewhere on Google. I do not know if it has to do with what I want.

    Sub OpenFileAndWait()
    Dim sApp As String
    
    '// Define the Application FullPath here
    sApp = "C:\A\Batch.bat"
    'sApp = "C:\windows\system32\calc.exe"
    
    '// Lets DoIt
    ShellAndWait sApp
    '// Tell me if Successful
    MsgBox "Finished running task!"
    
    End Sub

     Sub IsTaskRunning()
          ' If file does not exist, GoTo error trap.
          On Error GoTo itrErrTrap
          ' Run sample batch file in MS-DOS window.
          Shell "c:\test.bat"
          Do
             ' Note: When specifying the Application name
             ' with the Exists(Name) argument, omit the
             ' Application extension.
             test = Tasks.Exists("test")
          Loop Until  test = 0
          MsgBox "The application has quit."
       itrErrTrap: ' Note: This line must be left aligned.
          If Err > 0 then MsgBox Err.Description
       End Sub
    I get here a message: Object required


    If anyone can help me I appreciate it.


    Best regards,

    grid

    Last edited by grid; 01-06-2010 at 03:55 PM. Reason: Solved

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