SuperHeMan
New Member
- Joined
- Nov 30, 2014
- Messages
- 6
Hi,
I am new here in this forum so please bear with me if I ask a "dumb" question!
I have made a daily sales report that I run every morning and send to my colleagues. To avoid this simple task I would like to use VBA to auto-execute this on a computer that stay turned on 24/7.
So my thought is that the file should just stay open on this computer and self execute the macro that updates the file, save it, send the file to a predetermined mailing list and print x copies at 06:00 every morning (monday-friday).
I have tried to google this, but am not able to get the VBA code to work. This is what I have so far:
Private Sub Workbook_open()
application.OnTime TimeValue("06:00:00"), "UpdateSalesReport"
End Sub
Sub UpdateSalesReport()
application.ScreenUpdating = False
Sheets("IWH").Select
Connect_Retrieve ("IWH")
application.StatusBar = False
Sheets("Weekly Sales").Select
Range("a1").Select
application.ScreenUpdating = False
ActiveWorkbook.Save
End Sub
My understanding is that the first "sub" only execute when the workbook is opened, not if it stay opened?!? Anyways, I am not able to get it to work when I open the file or if I leave it open....
Do you have any suggestions to how I can solve this?
Thx
I am new here in this forum so please bear with me if I ask a "dumb" question!
I have made a daily sales report that I run every morning and send to my colleagues. To avoid this simple task I would like to use VBA to auto-execute this on a computer that stay turned on 24/7.
So my thought is that the file should just stay open on this computer and self execute the macro that updates the file, save it, send the file to a predetermined mailing list and print x copies at 06:00 every morning (monday-friday).
I have tried to google this, but am not able to get the VBA code to work. This is what I have so far:
Private Sub Workbook_open()
application.OnTime TimeValue("06:00:00"), "UpdateSalesReport"
End Sub
Sub UpdateSalesReport()
application.ScreenUpdating = False
Sheets("IWH").Select
Connect_Retrieve ("IWH")
application.StatusBar = False
Sheets("Weekly Sales").Select
Range("a1").Select
application.ScreenUpdating = False
ActiveWorkbook.Save
End Sub
My understanding is that the first "sub" only execute when the workbook is opened, not if it stay opened?!? Anyways, I am not able to get it to work when I open the file or if I leave it open....
Do you have any suggestions to how I can solve this?
Thx