Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Run macro on open IF its before 9:00 AM

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ChrisR - 22 Mar 2006 23:45 GMT
I am trying to write an Auto_Open query that will refresh a workbooks
MSQueries (activeworkbook.refreshall) but ONLY if it is opened before 9:00
AM.  I do this because I have a scheduler open a number of files before I
get into the office and want the refreshed done before I get there  They
take a while so for the same reason I don't want them to refresh when I open
them later in the day to work on them or when other users open them after
they get into the office.

Trying this...

Sub Auto_Open()
If Time < "09:00:00" Then
HandRefreshBigPrice
Else
End If
End Sub

Where HandRefreshBigPrice is another macro that does the refresh all
function and posts the time of refresh to a hidden column.

My problem is that Excel doesn't seem to handle time the way I am expecting.
If I run this macro before 9 AM in the morning nothing happens.  Then later
in the day it refreshes.  Its like its opposite or something.  Do I have to
somehow incorporate the day and not just the time?  Is there some easier way
to make this simple task automated?

Any help would be greatly appreciated.

c-
N10 - 23 Mar 2006 00:10 GMT
Hi

This worked for me ;

Private Sub Workbook_Open()

Dim k

k = Time

If Time < "09:00:00" Then Call HandRefreshBigPrice

End Sub

Best N10

>I am trying to write an Auto_Open query that will refresh a workbooks
> MSQueries (activeworkbook.refreshall) but ONLY if it is opened before 9:00
[quoted text clipped - 30 lines]
>
> c-
N10 - 23 Mar 2006 00:15 GMT
Correction
Hi

This worked for me ;

Private Sub Workbook_Open()

Dim k

k = Time

If  k  < "09:00:00" Then Call HandRefreshBigPrice

End Sub

Best N10

> Hi
>
[quoted text clipped - 47 lines]
>>
>> c-
PaulD - 23 Mar 2006 00:21 GMT
Since you are working with a date/time variable and not a string, try this
instead

If Time < #9:00:00 AM# Then
...
Paul D

: I am trying to write an Auto_Open query that will refresh a workbooks
: MSQueries (activeworkbook.refreshall) but ONLY if it is opened before 9:00
[quoted text clipped - 25 lines]
:
: c-
Dave Peterson - 23 Mar 2006 01:13 GMT
And one more:

if time < timeserial(9,0,0) then

> I am trying to write an Auto_Open query that will refresh a workbooks
> MSQueries (activeworkbook.refreshall) but ONLY if it is opened before 9:00
[quoted text clipped - 25 lines]
>
> c-

Signature

Dave Peterson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.