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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -