Consulting

Results 1 to 4 of 4

Thread: Solved: help w/ ONTIME

  1. #1
    VBAX Regular
    Joined
    Mar 2008
    Posts
    16
    Location

    Solved: help w/ ONTIME

    Help! ...I've borrowed from other sources and can feel I'm close ...but can't make this macro work.
    I know the opening event triggers "starttimer" because the word 'Loaded' appears ...but the "refresher" macro doesn't run for some reason.
    Am I messing up somewhere? Maybe in the declaration? Pls Help!

    ...in ThisWkbk
    [vba]
    Private Sub workbook_open()
    Call starttimer
    End Sub

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Call stoptimer
    End Sub
    [/vba]
    ...in Module 1:
    [vba]
    Public Const cRunWhat = "refresher"
    Sub starttimer()

    Windows("myfile.XLS").Activate
    Sheets("GDR").Select
    Range("A2").Value = "loaded"

    Application.OnTime TimeSerial(13, 38, 0), cRunWhat, True

    End Sub

    Sub stoptimer()

    On Error Resume Next
    Application.OnTime RunWhen, cRunWhat, False

    End Sub

    Sub refresher()

    Range("A3").Value = "done"
    Windows("myfile.XLS").Activate
    Sheets("GDR").Select
    Range("d5:e15").Select
    Application.Run "RefreshCurrentSelection"
    Range("A4").Value = "done2"

    End Sub
    [/vba]
    Thanks,
    L

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Const cRunWhat = "refresher"
    Public RunWhen As Double

    Sub starttimer()

    Windows("myfile.XLS").Activate
    Sheets("GDR").Select
    Range("A2").Value = "loaded"

    RunWhen = TimeSerial(13, 38, 0)
    Application.OnTime RunWhen, cRunWhat, , True

    End Sub

    Sub stoptimer()

    On Error Resume Next
    Application.OnTime RunWhen, cRunWhat, , False

    End Sub

    Sub refresher()

    Range("A3").Value = "done"
    Windows("myfile.XLS").Activate
    Sheets("GDR").Select
    Range("d5:e15").Select
    Application.Run "RefreshCurrentSelection"
    Range("A4").Value = "done2"

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Const cRunWhat = "refresher"
    Public RunWhen As Double

    Sub starttimer()

    Windows("myfile.XLS").Activate
    Sheets("GDR").Select
    Range("A2").Value = "loaded"

    RunWhen = TimeSerial(13, 38, 0)
    Application.OnTime RunWhen, cRunWhat, , True

    End Sub

    Sub stoptimer()

    On Error Resume Next
    Application.OnTime RunWhen, cRunWhat, , False

    End Sub

    Sub refresher()

    Range("A3").Value = "done"
    Windows("myfile.XLS").Activate
    Sheets("GDR").Select
    Range("d5:e15").Select
    Application.Run "RefreshCurrentSelection"
    Range("A4").Value = "done2"

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Regular
    Joined
    Mar 2008
    Posts
    16
    Location
    XLD - Thanks ever so much for this. Really really appreciate it. Best. Lijon

Posting Permissions

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