Excel Locked by Scheduler,

jc.021286

Well-known Member
Joined
Apr 12, 2010
Messages
725
Morning,

Hoping someone can help identify how to work around this. I have the Windows 7 Task Scheduler open an excel file, it runs an on open macro that calls Refresh_all_tables, does what it needs and closes. However, it is now locked, I've tried changing the

Code:
Application.Quit
ThisWorkbook.Close

lines around to no avail.

I am the administrator, when I open the file it says that I've locked myself out of it and can only notify (does nothing) or read-only. Requires a full restart to clear. The "~$[excel sheet name].xlsm" is on the desktop where the file is and won't allow me to delete it.

Opening the file myself works perfectly every time,
The scheduler runs fine the first time.

I do not know what to do, except double click the file every day at 4 hour intervals... (I need sleep)

Thanks for any help on the matter, here is the main set of code that drives everything and completes fine the first scheduled run or any time it is not locked by myself on my PC.

jc

Code:
Private Sub Workbook_Open()
    Call Refresh_all_tables
End Sub
Sub Refresh_all_tables()
'
' Master macro for executing everything.
'

'
    Sheets("Report").Select
    Range("A1").Select
    ActiveWorkbook.RefreshAll
        
        
            
    Call Filter_Accounts
    Call generate_report
    Call check_for_new_devices
    Call Retrieve_last_replacement
    Call check_warning_levels
    
    Sleep (20000)
    
    ThisWorkbook.Save
    Application.Quit
    ThisWorkbook.Close
    
End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I believe this is working.

I'm running into VBS errors:
[h=1]Multiple-step OLE DB operation generated errors[/h]I'll try to trouble shoot these and see if it is possible to solve. At present it will open a VBS error message and I'm not sure if that will prevent the script from running in the future.

This seems to have corrected the locked file syndrome and replaced it with another...
jc
 
Upvote 0

Forum statistics

Threads
1,214,858
Messages
6,121,956
Members
449,057
Latest member
FreeCricketId

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top