Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default OnTime method only runs 1 time

Hi

I have a macro that runs a sub at a specific time. I have
set up a local macro that sets the timer when the workbook
is first opened to run a global macro at a specific time.
I often don't check the computer where this workbook is
for days at a time so I want to be able to just open the
workbook once and have the macro run every day at 3:00.
The local code is:

Private Sub Workbook_Open()

Dim Activate_Online_Historical As String

Application.OnTime _
earliestTime:=TimeValue("15:00:00"), _
Procedu="Activate_Online_Historical"

End Sub

It works the first day but not the next unless I close and
reopen. Thanks in advance.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default OnTime method only runs 1 time

Got it - Thanks Bob and Chip.

-----Original Message-----
JP,

The following code needs to be all on one single line

Application.OnTime TimeValue("15:00:00"), "my_Procedure"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"JP" wrote in message
...
Hi

Thanks for your reply Bob, but I can't figure out how to
use your code. When replace

Application.OnTime _
earliestTime:=TimeValue("15:00:00"), _
Procedu="Activate_Online_Historical"


with

Application.OnTime TimeValue

("15:00:00"), "), "my_Procedure"

I get the error:

Compile Error:
Expected: End of Statement

Do you know what I'm doing wrong?

Thanks again.

-----Original Message-----
JP,

In the macro that is run, or at the completion of that

macro, you need to
reset the OnTime method for 1 day hence
Application.OnTime TimeValue

("15:00:00"), "), "my_Procedure"
--
HTH

-------

Bob Phillips
... looking out across Poole Harbour to the

Purbecks


"JP" wrote in message
...
Hi

I have a macro that runs a sub at a specific time. I

have
set up a local macro that sets the timer when the

workbook
is first opened to run a global macro at a specific

time.
I often don't check the computer where this workbook

is
for days at a time so I want to be able to just open

the
workbook once and have the macro run every day at

3:00.
The local code is:

Private Sub Workbook_Open()

Dim Activate_Online_Historical As String

Application.OnTime _
earliestTime:=TimeValue("15:00:00"), _
Procedu="Activate_Online_Historical"

End Sub

It works the first day but not the next unless I

close
and
reopen. Thanks in advance.




.



.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default OnTime method only runs 1 time


"JP" wrote in message
...
Hi

I have a macro that runs a sub at a specific time. I have
set up a local macro that sets the timer when the workbook
is first opened to run a global macro at a specific time.
I often don't check the computer where this workbook is
for days at a time so I want to be able to just open the
workbook once and have the macro run every day at 3:00.
The local code is:

Private Sub Workbook_Open()

Dim Activate_Online_Historical As String

Application.OnTime _
earliestTime:=TimeValue("15:00:00"), _
Procedu="Activate_Online_Historical"

End Sub


Id suggest using the CustomProperties collection of the workbook

example

Public Sub SaveHistoricalTime(OpenTime as String)
On Error Resume Next
ActiveWorkbook.CustomDocumentProperties("OnTime"). Delete

ActiveWorkbook.CustomDocumentProperties.Add Name:="OnTime",
LinkToContent:=False, _
Type:=msoPropertyTypeString, value:=OpenTime

End Sub
This will be saved with the workbook

Keith


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
VBA macro runs fine, but freezes if I try to do ANYTHING else whileit runs Rruffpaw Setting up and Configuration of Excel 1 September 17th 11 01:25 PM
Office 2007 Configuration wizard runs every time I start anyApplication Erik[_3_] Setting up and Configuration of Excel 0 June 12th 09 07:39 PM
Find %ontime & SUMIF ontime ie: find matching sets within Range... Chris T-M Excel Worksheet Functions 3 October 10th 08 08:14 PM
Office 2007 Configuration wizard runs every time I start anyApplication (word, excel, etc) [email protected] Setting up and Configuration of Excel 1 January 15th 08 07:44 PM
Unprotect method run-time error Rohit Thomas Excel Programming 0 July 8th 03 07:32 PM


All times are GMT +1. The time now is 09:59 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"