Tom,
Strange - only Double works for me - if I specify single, no discernible
delay takes place. Anyway, as long as one way works (but if you're anything
like me, you don't like loose ends either!)
Cheers
Pete
"Tom Ogilvy" wrote:
> Sub BB()
> Dim WaitTime1 As Single
>
> ' WaitTime1 = TimeSerial(0, 0, 10)
> WaitTime1 = TimeValue("0:0:10")
> Debug.Print Now, Now + WaitTime1
> Application.Wait Now + WaitTime1
> Debug.Print Now
> End Sub
>
> worked for me. Both using TimeSerial and TimeValue
>
> --
> Regards,
> Tom Ogilvy
>
> "Peter Rooney" <PeterRooney@discussions.microsoft.com> wrote in message
> news:0BB2AAA2-9299-485A-8024-4D5A7B3DD996@microsoft.com...
> > Tom,
> >
> > This is great, thanks!
> > I got my original code from Excel help!!!
> >
> > One thing, when I declare a the WaitTime1 variable, the code only works
> > correctly if I give specify type Variant or Double. I know I can't use
> > integer or long, as they only wotk with integers, but do you have any idea
> > what's wrong with "single" in this instance?
> >
> > Thanks
> >
> > Pete
> >
> > "Tom Ogilvy" wrote:
> >
> > > I would suspect that the help example you copied is flawed. to
> > > demonstrate:
> > >
> > > Sub BB()
> > > newHour = Hour(Now())
> > > newMinute = Minute(Now())
> > > newSecond = Second(Now()) + 10
> > > waittime = TimeSerial(newHour, newMinute, newSecond)
> > > waittime1 = Now + TimeValue("0:00:10")
> > > Debug.Print waittime, waittime1
> > > Debug.Print CSng(waittime), CSng(waittime1)
> > > End Sub
> > >
> > > Produces:
> > > 7:51:28 AM 09/08/2005 7:51:28 AM
> > > 0.3274074 38603.33
> > >
> > > Use this instead:
> > >
> > > newHour = Hour(Now())
> > > newMinute = Minute(Now())
> > > newSecond = Second(Now()) + 10
> > > waittime = TimeSerial(newHour, newMinute, newSecond)
> > > Application.Wait Date + waittime
> > >
> > > or just
> > >
> > > waittime1 = Now + TimeValue("0:00:10")
> > > Application.Wait WaitTime1
> > >
> > > --
> > > Regards,
> > > Tom Ogilvy
> > >
> > >
> > > "Peter Rooney" <PeterRooney@discussions.microsoft.com> wrote in message
> > > news:DBC8BFE4-58AB-499B-B0B2-3D2C4F4E602F@microsoft.com...
> > > > Good afternoon,
> > > >
> > > > Can anyone explain why the following code doesn't take 30 seconds to
> > > run...
> > > > or when called from within another macro, doesn't delay macro
> execution by
> > > 30
> > > > seconds?
> > > >
> > > > Thanks in advance
> > > >
> > > > Sub HoldOnABit()
> > > >
> > > > Dim NewHour As Integer
> > > > Dim NewMinute As Long
> > > > Dim NewSecond As Long
> > > > Dim WaitTime As Long
> > > >
> > > > NewHour = Hour(Now())
> > > > NewMinute = Minute(Now())
> > > > NewSecond = Second(Now()) + 30
> > > > WaitTime = TimeSerial(NewHour, NewMinute, NewSecond)
> > > >
> > > > Application.Wait WaitTime
> > > >
> > > > End Sub
> > > >
> > > >
> > > > Pete
> > > >
> > > >
> > >
> > >
> > >
>
>
>
Bookmarks