Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add delay between commands in VB

Status
Not open for further replies.

mauricionava

Programmer
Jul 8, 2005
209
US
Hello, I have a batch file that runs with a button and after the batch file runs I have some more coding that does not work until the process in the batch file finishes. How can I insert a delay between the batch file command and the rest of the code behind the button?

Thanks a lot.

This is the code:
Code:
Dim stAppName As String
Dim loanPath As String
Dim dealerPath As String
Dim userPath As String


stAppName = "\\Nal-01\data\Information Tech\LOS3\CloseTifViewer.bat"
Call Shell(stAppName, 1)

** I NEED TO INSERT DELAY HERE **

loanPath = "W:\" & Me.cmbDealerShort.Value & "\" & Me.txtAcct.Value & " - " & Me.txtBUYER.Value ' this is the account folder
dealerPath = "W:\" & Me.cmbDealerShort.Value ' this is the main dealer folder
userPath = "\\nal-file01\Production\UserFaxQ\" & Me.quserid.Value ' this is the user's queue folder for faxes

'MkDir "\\nal-file01\Production\UserFaxQ\" & Me.quserid.Value

Dim fso
Dim sfolder As String, dfolder As String ' sfolder is Source Folder. dfolder is Destination Folder.

sfolder = userPath 
dfolder = loanPath 

Set fso = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
If Not fso.FolderExists(sfolder) Then
    MsgBox "The folder/path " & sfolder & " has not been created.", vbInformation, "Invalid Source"
ElseIf Not fso.FolderExists(dfolder) Then
    MsgBox "The folder/path " & dfolder & " is not valid.", vbInformation, "Invalid Destination"
Else
    fso.MoveFile (sfolder & "\*.*"), dfolder
End If
If Err.Number = 53 Then MsgBox "Files not found in the temporary fax folder.", vbInformation, "No Files Found"
 
Replace this:
Call Shell(stAppName, 1)
with this:
CreateObject("WScript.Shell").Run Chr(34) & stAppName & Chr(34), 1, True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top