+ Reply to Thread
Results 1 to 7 of 7

Workaround for com exe timer?? help

  1. #1
    Nicole Seibert
    Guest

    Workaround for com exe timer?? help

    Hi fellow helpers,
    I created this little ditty so that I wouldn't have to write the far more
    complex
    ActiveX exe (and because I have never written an ActiveX exe). The problem
    is I get an error with the following code on the starttime = now line.

    Dim c As Integer, starttimer As Integer

    c = 0
    starttimer = Now() (I have also tried this: starttimer = Format(Now,
    "h:mm:ss"))

    Do While c = 0
    If Range("A2") <> "" Then c = 1
    If c = 1 Then Exit Do
    If Now > starttimer + TimeValue("0, 30, 0") Then GoTo KICKIT
    Loop

    I think what is happening is that starttimer may be continually updating to
    reflect "NOW", but I don't want it to do this. Is there a way to capture
    current time without it updating?

    Thanks,
    Nicole

  2. #2
    Jim Cone
    Guest

    Re: Workaround for com exe timer?? help

    Nicole,
    Maybe this is what you want...
    '---------------
    Dim c As Integer, startTimer As Single
    c = 0
    startTimer = Timer

    Do While c = 0
    If Range("A2") <> "" Then c = 1
    If c = 1 Then Exit Do
    If Timer > startTimer + 30 Then GoTo KickIt
    Loop
    KickIt:
    --
    Jim Cone
    San Francisco, USA
    http://www.realezsites.com/bus/primitivesoftware


    "Nicole Seibert"
    <[email protected]>
    wrote in message
    Hi fellow helpers,
    I created this little ditty so that I wouldn't have to write the far more
    complex
    ActiveX exe (and because I have never written an ActiveX exe). The problem
    is I get an error with the following code on the starttime = now line.

    Dim c As Integer, starttimer As Integer

    c = 0
    starttimer = Now() (I have also tried this: starttimer = Format(Now,
    "h:mm:ss"))

    Do While c = 0
    If Range("A2") <> "" Then c = 1
    If c = 1 Then Exit Do
    If Now > starttimer + TimeValue("0, 30, 0") Then GoTo KICKIT
    Loop

    I think what is happening is that starttimer may be continually updating to
    reflect "NOW", but I don't want it to do this. Is there a way to capture
    current time without it updating?

    Thanks,
    Nicole

  3. #3
    Norman Jones
    Guest

    Re: Workaround for com exe timer?? help

    Hi Nicole,

    Try declaring startTimer as double:

    Dim c As Long
    Dim startTimer As Double


    An Integer data type can only hold values in the range -32,768 to 32,767.

    From the intermediate window:

    ?CDbl(Now)

    38913.7293171296


    ---
    Regards,
    Norman



    "Nicole Seibert" <[email protected]> wrote in message
    news:[email protected]...
    > Hi fellow helpers,
    > I created this little ditty so that I wouldn't have to write the far more
    > complex
    > ActiveX exe (and because I have never written an ActiveX exe). The
    > problem
    > is I get an error with the following code on the starttime = now line.
    >
    > Dim c As Integer, starttimer As Integer
    >
    > c = 0
    > starttimer = Now() (I have also tried this: starttimer = Format(Now,
    > "h:mm:ss"))
    >
    > Do While c = 0
    > If Range("A2") <> "" Then c = 1
    > If c = 1 Then Exit Do
    > If Now > starttimer + TimeValue("0, 30, 0") Then GoTo KICKIT
    > Loop
    >
    > I think what is happening is that starttimer may be continually updating
    > to
    > reflect "NOW", but I don't want it to do this. Is there a way to capture
    > current time without it updating?
    >
    > Thanks,
    > Nicole




  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Nicole,

    Your timer is set to run for a maximum of 30 minutes from when it is started. While your timer is running Excel can't be updated. Range("A2") won't change until the timer has expired. This is why you need to use an ActiveX timer or an API timer.

    Sincerely,
    Leith Ross

  5. #5
    Nicole Seibert
    Guest

    Re: Workaround for com exe timer?? help

    I am going for 30 minutes. My understanding is that the default for time is
    seconds; Is this true? Then i would need 1800 seconds asking that no other
    processes run.

    Also, for the record, KICKIT goes back to the beginning of the SQL Query
    request. I am asking that all further processes are suspended and if the
    query is not sucessful to restart it after 30 minutes.

    Intuitively this has me a little worried since i have already declared the
    variables. Do I have to set them to nothing before I declare them again?

    Thank you,
    Nicole

    "Jim Cone" wrote:

    > Nicole,
    > Maybe this is what you want...
    > '---------------
    > Dim c As Integer, startTimer As Single
    > c = 0
    > startTimer = Timer
    >
    > Do While c = 0
    > If Range("A2") <> "" Then c = 1
    > If c = 1 Then Exit Do
    > If Timer > startTimer + 30 Then GoTo KickIt
    > Loop
    > KickIt:
    > --
    > Jim Cone
    > San Francisco, USA
    > http://www.realezsites.com/bus/primitivesoftware
    >
    >
    > "Nicole Seibert"
    > <[email protected]>
    > wrote in message
    > Hi fellow helpers,
    > I created this little ditty so that I wouldn't have to write the far more
    > complex
    > ActiveX exe (and because I have never written an ActiveX exe). The problem
    > is I get an error with the following code on the starttime = now line.
    >
    > Dim c As Integer, starttimer As Integer
    >
    > c = 0
    > starttimer = Now() (I have also tried this: starttimer = Format(Now,
    > "h:mm:ss"))
    >
    > Do While c = 0
    > If Range("A2") <> "" Then c = 1
    > If c = 1 Then Exit Do
    > If Now > starttimer + TimeValue("0, 30, 0") Then GoTo KICKIT
    > Loop
    >
    > I think what is happening is that starttimer may be continually updating to
    > reflect "NOW", but I don't want it to do this. Is there a way to capture
    > current time without it updating?
    >
    > Thanks,
    > Nicole
    >


  6. #6
    Nicole Seibert
    Guest

    Re: Workaround for com exe timer?? help

    Okay. So, I won't user timer. And yes, i know I should be learning the
    ActiveX stuff and I will... i about two minutes. But why wouldn't my
    original code work -- I didn't use timer?

    Thanks,
    Nicole

    "Leith Ross" wrote:

    >
    > Hello Nicole,
    >
    > Your timer is set to run for a maximum of 30 minutes from when it is
    > started. While your timer is running Excel can't be updated.
    > Range("A2") won't change until the timer has expired. This is why you
    > need to use an ActiveX timer or an API timer.
    >
    > Sincerely,
    > Leith Ross
    >
    >
    > --
    > Leith Ross
    > ------------------------------------------------------------------------
    > Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
    > View this thread: http://www.excelforum.com/showthread...hreadid=561743
    >
    >


  7. #7
    Bob Phillips
    Guest

    Re: Workaround for com exe timer?? help

    I wouldn't use this, but the errors are gone

    Dim co As Long
    Dim starttimer As Double

    c = 0
    starttimer = Now()

    Do While c = 0
    If Range("A2") <> "" Then c = 1
    If c = 1 Then Exit Do
    If Now > starttimer + TimeValue("0:30:00") Then GoTo KICKIT
    Loop


    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "Nicole Seibert" <[email protected]> wrote in message
    news:[email protected]...
    > Okay. So, I won't user timer. And yes, i know I should be learning the
    > ActiveX stuff and I will... i about two minutes. But why wouldn't my
    > original code work -- I didn't use timer?
    >
    > Thanks,
    > Nicole
    >
    > "Leith Ross" wrote:
    >
    > >
    > > Hello Nicole,
    > >
    > > Your timer is set to run for a maximum of 30 minutes from when it is
    > > started. While your timer is running Excel can't be updated.
    > > Range("A2") won't change until the timer has expired. This is why you
    > > need to use an ActiveX timer or an API timer.
    > >
    > > Sincerely,
    > > Leith Ross
    > >
    > >
    > > --
    > > Leith Ross
    > > ------------------------------------------------------------------------
    > > Leith Ross's Profile:

    http://www.excelforum.com/member.php...o&userid=18465
    > > View this thread:

    http://www.excelforum.com/showthread...hreadid=561743
    > >
    > >




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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