I have created a macro that downloads data from the web. Since this
data on the website is updating constantly, I need to rerun my
download macro every hour or every 30 minutes or whatever I ultimately
decide.
I am using Windows Scheduled Tasks to open the workbook at the desired
intervals; and upon opening, the macro is executed.
My goal here is to have the entire procedure repeat itself
automatically for hours on end if I am not available.
Because of an obnoxious "read only" popup that I can't get around, I
cannot automatically run my procedure unless Excel is closed at the
time of the scheduled event.
For this reason I have added another procedure that saves the workbook
and closes Excel 5 minutes after the workbook is opened (so that it
will be closed when the time comes for the next execution).
It works better than it sounds--Everything works as desired up to this
point.
My question deals with the situation which occurs when it comes time
for the scheduled task AND I am working with Excel AND I do not want
Excel to close automatically.
I would like to insert an Input Box which gives me the option of
aborting the "automatic Excel close" and if I have not made the
appropriate response within, say, 20 seconds, then the automatic
procedure goes ahead and does its thing.
To this end, I have gotten this far:
................................................................
Dim Msg As String, Title As String
Dim Config As Integer, Ans As Integer
Msg = "Unless you intervene now, ALL EXCEL WILL CLOSE in 2 Minutes"
Msg = Msg & " with no further warnings and you will LOSE any"
Msg = Msg & " unsaved material."
Msg = Msg & vbNewLine & vbNewLine
Msg = Msg & "Do you want to STOP EXCEL FROM CLOSING?"
Title = "Excel About to Close Automatically!"
Config = vbYesNo + vbCritical + vbDefaultButton2
Ans = MsgBox(Msg, Config, Title)
If Ans = vbYes Then
Exit Sub
Else: Application.OnTime Now + TimeValue("00:02:00"), "EndShow"
End If
.................................................................
My problem, of course, is that the procedure as written requires a yes
or no answer before it will do anything; whereas what I want it to do
is assume a "no" answer after 20 seconds if a "yes" answer has not
been entered.