An object-oriented programming language developed by Microsoft that can be used in .NET.
Hi @Rick Crosby ,
Please let me know how the tests suggested by Marcin go, particularly whether the task works with “Run only when user is logged on.”
To add some context on why this happens: when a task is set to “Run whether user is logged on or not,” it runs in a non interactive session with no loaded user desktop and a limited Office profile. Excel automation depends on that profile for things like temporary folders, HKEY_CURRENT_USER settings, and file locking. If Excel cannot create its lock file next to the workbook in that session, it silently falls back to opening the file as read only instead of returning an error. That is why the same script behaves differently between a manual run and a scheduled run, and why the Open(WkbMain, False, False) call is not the cause here.
If the issue persists, please share:
- The workbook’s storage location, local drive or network share. Network shares and mapped drives are a common failure point because mapped drives are not available in a non interactive session, so a UNC path is required.
- The result of the ReadOnly check right after the workbook is opened.
- Any error message from the macro or the save operation.
- The account the task runs under, and whether “Run with highest privileges” is enabled.
Also worth confirming that the account running the task has Modify or Write permission on the folder containing the workbook, not just on the workbook itself, since Excel needs to create the lock file in that folder.
These details will help me narrow down the cause.
Thank you.