+ Reply to Thread
Results 1 to 2 of 2

Application.OnTime TimeValue Running at unspecified Times

  1. #1
    Registered User
    Join Date
    10-30-2013
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2010
    Posts
    1

    Post Application.OnTime TimeValue Running at unspecified Times

    I want to use an external device to scan and measure voltage. I want to run a scan every 6 hours. The code I used to do that is as follows.

    -----------------------------------------------------------------------------------------------------
    Private Sub Workbook_Open()
    'Runs a voltage scan at 9:00am, 3:00pm, 9:00pm, and 3:00am

    Application.OnTime TimeValue("03:00:00"), "Scan34970A"
    Application.OnTime TimeValue("09:00:00"), "Scan34970A"
    Application.OnTime TimeValue("15:00:00"), "Scan34970A"
    Application.OnTime TimeValue("21:00:00"), "Scan34970A"

    End Sub

    ------------------------------------------------------------------------------------------------------

    However, when I run the macro I am having the "Scan34970A" fire at times that are undesired. Also the scan will occasionally run several times when the scan is called at the times specified.

    How would I get the scan to ALWAYS run only once, and only at the times requested?

    Thank you for the support ,

    JD

  2. #2
    Forum Contributor
    Join Date
    04-24-2007
    Location
    NYC
    MS-Off Ver
    2k3/2k7/2010
    Posts
    270

    Re: Application.OnTime TimeValue Running at unspecified Times

    Instead of having the workbook check what time it is, i recommend using windows task schedule and schedule a task to open the workbook at your designated time. Then change your workbook to run the macro once when it opens.

+ 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] VBA macro application.ontime timevalue error
    By Jack7774 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-05-2013, 11:58 AM
  2. Reset Application.OnTime Now + TimeValue
    By cg0789 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2013, 01:00 AM
  3. Application.Ontime running as soon as WB is opened.
    By jasonfish11 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-30-2012, 01:05 PM
  4. [SOLVED] Application.OnTime Now + TimeValue problem...
    By michaeljoeyeager in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-24-2012, 04:42 PM
  5. Macro will not launch using Application.OnTime TimeValue
    By Josh Colton in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-07-2012, 06:26 PM

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