Reputation: 1
I'm working on a project to update production notes in a manufacturing schedule. I've a macro written to pull in the data to the manufacturing schedule, but I need to execute the macro in the file automaticaly every 15 minutes, but only while the user has the manufacturing schedule open. I've tried using "Application.OnTime" with specific times, but this seems to open the manufacturing schdule if its closed . I'm pretty new to VBA so any assistance with the code would be much appreciated. The code I'm using is pretty basic:
Private Sub Workbook_Open()
'Application.OnTime TimeValue("08:00:30"), "Open_SFCDB"
'Application.OnTime TimeValue("08:16:30"), "Open_SFCDB"
'Application.OnTime TimeValue("08:32:30"), "Open_SFCDB"
'Application.OnTime TimeValue("08:48:30"), "Open_SFCDB"
'Application.OnTime TimeValue("09:04:30"), "Open_SFCDB"
......Etc, Etc for 24 hr period
'End Sub`
Upvotes: 0
Views: 673
Reputation: 751
You might want to put your Application.OnTime procedure in a second workbook. Have it check if your manufacturing schedule is open when it runs.
Upvotes: 1
Reputation: 7289
Try and make it the active workbook and only proceed on success.
On Error Resume Next
Workbooks("ManufacturingSchedule").Activate
If Err <> 0 then
.... do your update etc ....
end if
Upvotes: 0