

If Excel is still open then the timer does continue to run if you do not turn it off with the closing macro.Īnd you are also correct that I always close Excel when I close the workbook.

ActiveDirectory with VBA Part 2 - Technet AD LDS S.Wow! What a detailed reply! It is completely correct.ActiveDirectory with VBA Part 3 - Technet AD LDS D.

ActiveDirectory with VBA Part 4 - ADSI Edit.ActiveDirectory with VBA Part 5 - Querying LDAP wi.ActiveDirectory with VBA Part 6 - Extending the AD.
EXCEL APPLICATION ONTIME PLUS
EXCEL APPLICATION ONTIME WINDOWS

'* even if that means checking more than once '* check for cancel here for cases when background task stop scheduling it '* yield control to OnTime scheduled procedures '* delete the dictionary resets the stateĪpplication.OnTime Now(), "SomeTaskToGetOnWith" HProc = OpenProcess(SYNCHRONIZE + PROCESS_QUERY_LIMITED_INFORMATION, False, hProg) HProg = Shell("notepad.exe", vbNormalFocus) 'hProg = Shell(Environ("comspec") & " /s /c notepad.exe ") Private mdicBackgroundTask As New Scripting.DictionaryĬonst PROCESS_QUERY_LIMITED_INFORMATION As Long = &H1000 (ByVal hProcess As LongPtr, lpExitCode As Long) As Long Private Declare PtrSafe Function GetExitCodeProcess Lib "kernel32" _ Private Declare Function CloseHandle Lib "kernel32" _ Private Declare Function OpenProcess Lib "kernel32" _ This is fine because all the user really cares about is a responsive GUI. Using this technique, we can give the illusion of multiple tasks going on. This is actually better described as timeslicing, since VBA is single threaded. Only when OnTime scheduled procedures have been exhausted does control return to the "normal" code. We can schedule snippets of work using Application.OnTime which can reschedule themselves to keep going.īut we need to know when to stop, so we need a Cancel checking routine, it turns out you'll need to check the cancel also in a procedure scheduled with OnTime.
EXCEL APPLICATION ONTIME CODE
I saw someone else's blog today that launched a process and checked the error code to see when it terminates, they suggested waiting between each check.
