title: Force a macro to stop after certain time VBA
body: <p>I have a process where I use VBA to enter a webpage and download a daily file around 6 pm, although this certain file can be uploaded any time later.
  Since I need to schedule automatic run for this macro because not always I will be able to run it manually (nor other person), I was thinking if there's some way to stop a macro execution after some time has passed. This is because, after the download, it should do some other things, but also the download takes a while, so if I do</p>
  <pre><code>Dir(file)
    Do While file = &quot;&quot;
    Do events
    ' CODE TO EXIT LOOP AFTER SOME TIME
  Loop
  </code></pre>
  <p>The code can be hours stuck because there is no file available on the webpage, so I would like that loop to break after, let's say, 1 minute. So maybe I was thinking to catch the current time and adding the time I want it to run and then on each loop compare the current time with the time I set to stop, and then break the loop, however, I don't get how to do the time part.</p>
  <p>Any help will be appreciated</p>