Hello all,
I have a code that will search to see if a window pops up (In this example a Save As Window), once the window pops up, my copied cell will be pasted and entered into the box. It seemed to work sometime ago, but now I can't figure out why it isn't. Any help with tweaking this code would be greatly appreciated.
I have a code that will search to see if a window pops up (In this example a Save As Window), once the window pops up, my copied cell will be pasted and entered into the box. It seemed to work sometime ago, but now I can't figure out why it isn't. Any help with tweaking this code would be greatly appreciated.
VBA Code:
Sub ShowMeTheFile1()
Const MAX_WAIT_SECS As Long = 25
Const WAIT_SECS As Long = 5
Dim hWnd As Long
Dim ans As VbMsgBoxResult
Dim endTime As Single
Sheets("DAILY02").Select
Range("G41").Select
Selection.Copy
endTime = Timer + MAX_WAIT_SECS
Do
hWnd = FindWindow(vbNullString, "Save As")
If hWnd > 0 Then
SetForegroundWindow hWnd
Application.SendKeys ("%v")
Application.SendKeys ("~")
Exit Do
End If
If Timer > endTime Then
ans = MsgBox("Window not found, try again?", vbQuestion + vbYesNo)
If ans = vbYes Then
endTime = Timer + MAX_WAIT_SECS
Else
Exit Do
End If
Else
PauseMacro WAIT_SECS
End If
Loop
End Sub