Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Run macro on open IF its before 9:00 AM

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-


  #2   Report Post  
Posted to microsoft.public.excel.programming
N10 N10 is offline
external usenet poster
 
Posts: 141
Default Run macro on open IF its before 9:00 AM

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

"ChrisR" wrote in message
...
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-




  #3   Report Post  
Posted to microsoft.public.excel.programming
N10 N10 is offline
external usenet poster
 
Posts: 141
Default Run macro on open IF its before 9:00 AM

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

"N10" wrote in message
...
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

"ChrisR" wrote in message
...
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-






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Run macro on open IF its before 9:00 AM

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

"ChrisR" wrote in message
...
: 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-
:
:


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Run macro on open IF its before 9:00 AM

And one mo

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



ChrisR wrote:

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-


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Excel file from VB and open MACRO no1jimmyman Excel Discussion (Misc queries) 0 February 14th 11 10:10 PM
open up an excel program with an auto open macro [email protected] Excel Programming 2 July 17th 05 04:48 PM
Macro - Open Word with Excel macro Bill Excel Discussion (Misc queries) 3 May 23rd 05 11:21 PM
ASP: Open Excel File with Macro, Allow Macro to run, and then save delgados129 Excel Programming 0 March 10th 05 09:35 PM
How do I get my personal macro worksheet to open whenever I open . Claudia_R Excel Discussion (Misc queries) 3 December 9th 04 11:59 PM


All times are GMT +1. The time now is 03:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"