Questo dove lo incollo?

Private Declare Function WaitForSingleObject Lib "KERNEL32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function OpenProcess Lib "KERNEL32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "KERNEL32" (ByVal hObject As Long) As Long
-----------------------------------------------------------------

E questo dove lo incollo?

Public Sub ShellWait(ByVal FileName As String, Optional WindowStyle As Variant)
Dim idProc As Long
Dim hProc As Long

idProc = VBA.Shell(FileName, WindowStyle)

hProc = OpenProcess(&H1F0FFF, False, idProc)
'attendi fine programma
If hProc <> 0 Then
Call WaitForSingleObject(hProc, INFINITE)
Call CloseHandle(hProc)
End If
End Sub