Hello all,
I really haven't mastered the concept of doing a loop in VBA (seriously need to find a good resource to practice with), however, I have a code that will find a window and pull it to the foreground, but if the window doesn't exist, I want to wait for five seconds and check again, now as I safety measure, I should perhaps put a two minute limit to prompt the user to retry for another two minutes or kill the code. Any help if getting the loop setup would be appreciated.
I really haven't mastered the concept of doing a loop in VBA (seriously need to find a good resource to practice with), however, I have a code that will find a window and pull it to the foreground, but if the window doesn't exist, I want to wait for five seconds and check again, now as I safety measure, I should perhaps put a two minute limit to prompt the user to retry for another two minutes or kill the code. Any help if getting the loop setup would be appreciated.
VBA Code:
Sub ShowIt2()
Dim hWnd As Long
hWnd = FindWindow(vbNullString, "Save As")
If hWnd > 0 Then SetForegroundWindow hWnd
Else
Application.Wait (Now + TimeValue("0:0:05"))