1

Does anyone have any idea, why the assignment

ActiveWorkbook.AutoSaveOn = False

inside Auto_Open might SPORADICALLY trigger runtime error 50289? Something about being unable to execute while Project is protected. Reloading the workbook has so far always overcome the problem. Re-running Auto_Open (via F8) does not cure the problem.

This is using Excel365, loading a file from SharePoint (via OneDrive).

Thanks.

Ollie2893
  • 427
  • 1
  • 5
  • 11
  • I answered a [while ago in relation to an add-in](https://stackoverflow.com/questions/40529060/excel-add-in-get-workbook-name-of-thisworkbook/40533271#40533271), but I suspect it's related to life cycle within excel. In first instance, if you don't have permits the first time you open the workbook that error will always come and you will need to handle it. – Sgdva Mar 25 '22 at 17:40
  • Thanks. You are saying that there is a race-condition. It is odd because the code is in the Auto_Open of the Workbook, so it seems weird that Excel could invoke the code before the Workbook is in. (The Workbook must be in for the code to be present.) Any suggestions as to how to handle it? Wait on what? – Ollie2893 Mar 27 '22 at 12:53
  • If the permissons are right, just add a [doevents](https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/doevents-function), or, you could try an on error goto and try to re do it 3 secs before throwing a real exception – Sgdva Mar 28 '22 at 14:06
  • As I just re-read my OP, it seems clear that a race-condition cannot be the problem. If it were just a matter of a few dominoes falling into place, manually running Auto_Open after the initial abort should succeed. But it does not. So the permissions aren't right, somehow. – Ollie2893 Mar 29 '22 at 17:28

0 Answers0