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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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