excel - Task Scheduler and Workbook Open macro -
i have code different things depending on time opened. using task scheduler open file. code runs part before second elseif
runs no problem. second elseif
not run when file opened task scheduler.
sub workbook_open() dim time_now string time_now = format(now, "hh:mm:ss") if time_now > "00:05:00" , time_now < "00:05:30" , thisworkbook.multiuserediting application.displayalerts = false thisworkbook.exclusiveaccess application.displayalerts = true application.calculation = xlcalculationautomatic thisworkbook.save application.quit elseif time_now > "00:05:00" , time_now < "00:05:30" , thisworkbook.multiuserediting = false application.quit elseif time_now > "00:10:00" , time_now < "00:11:00" application.displayalerts = false call sheet2.update if not activeworkbook.multiuserediting activeworkbook.saveas filename:=activeworkbook.fullname, accessmode:=xlshared end if application.displayalerts = true thisworkbook.save application.quit else end if end sub
if run code manually f8, there no problem. sheet2.update works no problem.
not quite sure why if can give pointers. thanks!
i believe macro trust settings blocking case when file opened task scheduler.
Comments
Post a Comment