When loading a file and then using this line:
```
package.Workbook.CreateVBAProject();
```
the file can get corrupted. This happens because <sheetPr codeName="" ...> is changed or set incorrectly.
I noticed that the "codeName" should be at max 22 chars long, but there are examples where longer names do work fine.
Examples:
```
<sheetPr codeName="This is a longer name abC" is ok and 25 characters long
<sheetPr codeName="1-This is a longer name a" is not ok and 25 characters long
<sheetPr codeName="1-This is a longer name" is not ok and 23 characters long
<sheetPr codeName="1-This is a longer nam" is ok and 22 characters long
```
Currently I have two workarounds which are not good.
1) Get "codeName" of all sheets, use the "CreateVBAProject" function and restore the "codeName"s
2) Use the "CreateVBAProject" function and trim the "codeName"s to 22 chars.
Best fix would be to not update the "codeName" if it exists or use at max 22 characters as the above examples show valid sheet names.
Or even better find out why some "codeName"s are ok and others not.
Comments: Fixed in changeset 33392c36678d
```
package.Workbook.CreateVBAProject();
```
the file can get corrupted. This happens because <sheetPr codeName="" ...> is changed or set incorrectly.
I noticed that the "codeName" should be at max 22 chars long, but there are examples where longer names do work fine.
Examples:
```
<sheetPr codeName="This is a longer name abC" is ok and 25 characters long
<sheetPr codeName="1-This is a longer name a" is not ok and 25 characters long
<sheetPr codeName="1-This is a longer name" is not ok and 23 characters long
<sheetPr codeName="1-This is a longer nam" is ok and 22 characters long
```
Currently I have two workarounds which are not good.
1) Get "codeName" of all sheets, use the "CreateVBAProject" function and restore the "codeName"s
2) Use the "CreateVBAProject" function and trim the "codeName"s to 22 chars.
Best fix would be to not update the "codeName" if it exists or use at max 22 characters as the above examples show valid sheet names.
Or even better find out why some "codeName"s are ok and others not.
Comments: Fixed in changeset 33392c36678d