borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (MS Project data access)Next Topic (Has the Document Changed?) New Topic New Poll Post Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : Daily scheduling of a macro
Poster Message
Psilocybin
Level: Protégé

Registered: 27-04-2005
Posts: 6

icon Daily scheduling of a macro

I have a macro which is set to run at a specific time each morning, during the week this runs fine as I close excel down during the day and open it again at night before I leave work.
At the weekend I set it going but it only works on saturday not on sunday or monday morning. I am pretty sure this is because there is no loop in the code and it simply runs it once. Is there any simple way of creating a loop or scheduling a macro which will do this for me? Here is my code;

Private Sub Workbook_Open()
application.OnTime TimeValue("07:35:01 am"), "conn"
application.OnTime TimeValue("07:35:30 am"), "mailinglist1"
End Sub

I tried this but the loop jus kept repeating and performs the task repetitively.

Private Sub Workbook_Open()
x = 1
Do
application.OnTime Now + TimeValue("00:15:00"), "conn"
application.OnTime TimeValue("07:35:30 am"), "mailinglist1"
Loop While x = 1
End Sub

Any help would be greatly appreciated.
Thanks
Psilocybin

[Edited by Psilocybin on 05-09-2005 at 10:11 AM GMT]

[Edited by Psilocybin on 05-09-2005 at 10:13 AM GMT]

____________________________
To be individual there must only be one!

05-09-2005 at 10:10 AM
View Profile Send Email to User Show All Posts | Quote Reply
~Bean~
Level: VB Guru


Registered: 07-04-2003
Posts: 488
icon Re: Daily scheduling of a macro

I wonder if there's a better way than Excel to do what you're doind...what are you doing in Excel?

Also, I wonder if you could use Scheduled Tasks to do this more easily...

I don't know any command line arguments for Excel but this worked for me...setup a scheduled task using:

c:\program files\microsoft office\office\excel.exe /n c:\filename.xls

____________________________
Eggheads unite! You have nothing to lose but your yolks.

20-09-2005 at 12:41 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
primfran
Level: Protégé

Registered: 03-06-2005
Posts: 5
icon Re: Daily scheduling of a macro

If you use Windows Task Scheduler (Start/Programs/Accessories/System Tools) you can set your code to run on open.

Also in your code you can close the file.

Set the schedule to run everyday and you don't have to run it manually even when you are there.

20-09-2005 at 09:11 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : Daily scheduling of a macro
Previous Topic (MS Project data access)Next Topic (Has the Document Changed?) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder