+ Reply to Thread
Results 1 to 6 of 6

Time Looped Data Acquisition - Command Button

  1. #1
    Registered User
    Join Date
    06-12-2015
    Location
    Pennsylvania
    MS-Off Ver
    2010
    Posts
    3

    Time Looped Data Acquisition - Command Button

    Greetings all,

    I posted a few days ago about this problem, with no responses, but I probably wasn't direct enough if my explanation. So I have a working code which sends a signal to a laboratory balance. Then the balance sends back the signal and excel places it into a cell along with a time stamp. The way the program works now is it is initiated by a command button. I'm looking for a way to put the process on a loop so that the command button is automatically clicked every 30 seconds or so. Or just do away with the command button and have the program loop on its own. I've been trying to use Application.OnTime however I'm not exactly sure where in my code to put it. When I put it in the CommandButton1_Click sub, the code seems to want to work (I click the button and it records data, then 30 seconds later it tries to run again but an error message occurs stating "Cannot run the macro ________. The macro may not be available in this workbook or all macros may be turned off." I've been trying alot of different things with no luck. Any help would be greatly appreciated. The first, short section here is under Microsoft Excel Objects/Sheet 1 (Results), and the second portion is under Forms/UserForm1.

    ----------------------------------------------------------------
    Please Login or Register  to view this content.
    Attached Images Attached Images

  2. #2
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: Time Looped Data Acquisition - Command Button

    the OnTim application is very finicky when it comes to permission. you might be having a issue because the macro is tied in to the sheet. Try this:

    Please Login or Register  to view this content.
    now create a module and insert this code (don't place it in the sheet)

    Please Login or Register  to view this content.
    the schedule is set to false on the first bit of code just so it runs once to call up the update_timer which will then cycle indefinitely. The key difference is it will be the update_timer macro to cycle, not the private commandbutton1_click

    I've worked with OnTime in the past and this thing is really moody. Give this a try and see how it goes.
    Last edited by JoeFoot; 06-16-2015 at 11:11 AM.
    Got help? Pls give rep.
    If you do R&D learn VBA

  3. #3
    Registered User
    Join Date
    06-12-2015
    Location
    Pennsylvania
    MS-Off Ver
    2010
    Posts
    3

    Re: Time Looped Data Acquisition - Command Button

    Well, I gave it a try, placing the suggested code in CommandButton1_Click Sub, and the second bit of code in a module (Module 1). The first data point does not appear, resulting in an error: "Run-time error '1004':
    Method 'OnTime' of object'_Application' failed. Any thoughts from here? Should the schtime be alerttime instead? In changing that nothing at all seems to happen when I press the command button.
    Last edited by janczar; 06-16-2015 at 02:16 PM.

  4. #4
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: Time Looped Data Acquisition - Command Button

    oh yeah my bad.

    replace schtime with alerttime

  5. #5
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: Time Looped Data Acquisition - Command Button

    here it is fixed:

    Please Login or Register  to view this content.
    now create a module and insert this code (don't place it in the sheet)

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: Time Looped Data Acquisition - Command Button

    When you press the commandbutton he should run the userform1.requestbalancedata at least 1 time.

    try setting the first schedule :=True instead of false

    on a separate note it did seem that your first problem was due to private macro permission.

+ 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. Automating command button for time dependent data acquisition
    By janczar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-13-2015, 03:36 AM
  2. [SOLVED] Command Button changes now cause Run Time Error 438
    By BFid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-11-2014, 11:25 AM
  3. Date and time by using the command button
    By dinesh009 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-16-2014, 01:09 AM
  4. [SOLVED] Command button will not execute all the time
    By fluce in forum Excel General
    Replies: 3
    Last Post: 10-02-2012, 04:51 PM
  5. Another command button... for zoom this time
    By torontoguy in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-22-2009, 10:40 AM

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