Results 1 to 9 of 9
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    know when the process is finished.... (2000 sr 1)

    I use this little shell command to lanch batch file to copy file from dir to other dir...
    When i use, vbhide the dos windows is hide and i dont know when the process is finished.
    Ho to know when the process is finished?

    Private Sub Form_Load()

    Shell "GCD01F4500DATIPUBBLICAxxcopyFILE_BATCHAGGIORNAMEN TO.BAT" ', vbHide

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: know when the process is finished.... (2000 sr 1)

    Is this in Excel or in VB6?

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: know when the process is finished.... (2000 sr 1)

    Excel i use in useform...

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: know when the process is finished.... (2000 sr 1)

    Hmm, why do you use Form_Load then?

  5. #5
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: know when the process is finished.... (2000 sr 1)

    Why not do the file copy in code so that you know when it has finished?
    Regards,
    Rory

    Microsoft MVP - Excel

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: know when the process is finished.... (2000 sr 1)

    You could also use this code
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: know when the process is finished.... (2000 sr 1)

    Similar to Rory's suggestion:

    Const INFINITE = &HFFFF

    Declare Function OpenProcess Lib "kernel32" _
    (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
    ByVal dwProcessId As Long) As Long

    Declare Function WaitForSingleObject Lib "kernel32" _
    (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

    Declare Function CloseHandle Lib "kernel32" _
    (ByVal hObject As Long) As Long

    Sub Test()
    Dim strCommand As String
    Dim lngPID As Long
    Dim lngHnd As Long
    Dim lngRet As Long

    strCommand = "GCD01F4500DATIPUBBLICAxxcopyFILE_BATCHAGGIORNAMEN TO.BAT"
    lngPID = Shell(strCommand, vbHide)

    If Not lngPID = 0 Then
    'Get a handle to the shelled process.
    lngHnd = OpenProcess(SYNCHRONIZE, 0, lngPID)

    'If successful, wait for the application to end and close the handle.
    If Not lngHnd = 0 Then
    lngRet = WaitForSingleObject(lngHnd, INFINITE)
    CloseHandle (lngHnd)
    End If

    MsgBox "Process finished.", vbInformation
    End If
    End Sub

  8. #8
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: know when the process is finished.... (2000 sr 1)

    Hi Hans... Big code!
    But the msgbox appear before the process of copy is finished...

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: know when the process is finished.... (2000 sr 1)

    It would be much easier to copy the file within the VBA code, as Rory suggested. You can use the FileCopy instruction for this.

Posting Permissions

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