• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Automating Excel macro to send email(incl. attach.) daily based on weekdays and specific time

VG_1

New Member
Hi,

I need some assistance. I want to automate an Excel macro using VBA that will send an email with attachment daily to recipients based on weekday and at specific times. For example, if today is a day between Monday - Friday then email will go out at 2:15 PM and 9:15 PM. And similarly for other days, i.e, Sat has other time intervals and Sunday has other time range.

I ran the code and it's working fine. But issue is, if I will run the macro today then it will send the email at above time only today and it will not work for next day, i.e, next day I've to restart the macro again. I am not able to understand as why do I have to restart the macro everyday and why not that same previous day's macro will continue for other days.

Would someone please help me with this? I am attaching a sample file with macros.

Please advise.

Thanks,
VG
 

Attachments

  • CheckWeekday_1.xlsm
    16.8 KB · Views: 30
Do you mean why do you need to open the file & run the macro every day?

Its because the code is part of Excel. So it is not an application independent code. So the only way to run it is to open the file & run it.

Otherwise you'll need to have an instance of Excel constantly open in the background which may stop you from carrying out other tasks because the code will keep looping.

To solve the problem of autorun when you do open the file however you could try running your macros in a "workbook open" event

If you still want to go down the route of running it without opening excel you'll need to delve into vbs. Example in link below

http://krgreenlee.blogspot.co.uk/2006/04/excel-running-excel-on-windows-task.html
 
Thanks for your reply. I mean why do I have to restart my macro everyday.
I don't close my file and it remains open. But the macro is just working for that day only not for other days.

Even if my excel file remains open, do I still have to schedule it using Windows task? Thanks.
----
Do you mean why do you need to open the file & run the macro every day?

Its because the code is part of Excel. So it is not an application independent code. So the only way to run it is to open the file & run it.

Otherwise you'll need to have an instance of Excel constantly open in the background which may stop you from carrying out other tasks because the code will keep looping.

To solve the problem of autorun when you do open the file however you could try running your macros in a "workbook open" event

If you still want to go down the route of running it without opening excel you'll need to delve into vbs. Example in link below

http://krgreenlee.blogspot.co.uk/2006/04/excel-running-excel-on-windows-task.html
 
Back
Top