+ Reply to Thread
Results 1 to 2 of 2

Macro to take a screenshot every few minutes works but encounters "400" error

  1. #1
    Registered User
    Join Date
    05-05-2019
    Location
    Philippines
    MS-Off Ver
    2007
    Posts
    1

    Macro to take a screenshot every few minutes works but encounters "400" error

    Good day!

    So this is the code I use to take screenshots of a certain program at a specific time interval.

    Please Login or Register  to view this content.
    This works perfectly at home but at work for some reason it encounters the 400 error after a few iterations. Last time I tried, it crashed after about 10 minutes. What I've observed is that the longer the wait time I set, the faster the macro crashes. Setting the wait time to 5 minutes, I can only take 2 screenshots and then the next one ends up with an error. I'm new to vba but maybe calling the sub which pastes (the screenshot to the excel file) within the sub crashes the whole thing? What I don't understand is when I'm at home I can even set the waiting time to 30 mins and the thing still works perfectly. I've tried it before and it worked for 6 hours or more without crashing.

    Alternately, how do I go about creating a separate sub for the waiting time and then looping that together with the screenshot+paste sub? So basically, I want to be able to create a macro that would be able to take a screenshot once I press run, wait 30 seconds for a new sheet to open and the second screenshot to be pasted, then wait another 30 minutes and repeat from the beginning. So far I've been able to do everything except the second waiting time of 30 mins. I want to be able to write a code with a loop do until function and just call the subs I will create but I don't know how to do it with the variables I have.

    Thanks in advance for any help.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to take a screenshot every few minutes works but encounters "400" error

    If you use WAIT you cannot do anything while Excel is 'waiting'
    Use AppliCation.OnTime, I suggest you google and read about this there a plenty samples
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro doesn't correctly replace "." with "," and getting Run-time error '1004'.
    By H.Gabor in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 07-26-2018, 06:36 AM
  2. Calculate "hours:minutes" difference between two "dates:times:minutes"
    By Neyme in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-26-2016, 11:03 PM
  3. Find a word "screenshot" and print value "yes" in adjacent Column
    By prat123 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-21-2015, 03:04 PM
  4. [SOLVED] Pasting values between ranges in different workbooks: "Range" works but "Cells" doesn't
    By Flaubert in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-13-2013, 01:19 PM
  5. Open files from FTP server (works with "servername" but doesn't work with "ip address")
    By adammsu1983 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-24-2012, 04:30 PM
  6. Macro Error with code "Range("A65536").End(xlUp).EntireRow.Insert"
    By lukasj13 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-30-2010, 08:48 PM
  7. Excel ver 10 "Encounters a Problem" on starting
    By Ken McLennan in forum Excel General
    Replies: 6
    Last Post: 07-19-2005, 09:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1