This one's got me stumped. I have an EXCEL VBA app that "clean-up" code in a Workbook_BeforeSave event. It unprotects the workbook, hides certain worksheets and make an "Intro" sheet visible, and then protects the workbook again.
This code (which I'll be happy to share if needed), works fine if I do an EXPLICIT SAVE from the menu.
I also have code in the Workbook_BeforeCLOSE event that also procedurally saves the workbook (thus invoking the BeforeSave event for the "clean-up" code). THIS IS WHERE THINGS GO HAYWIRE.
The same code that worked with the explicit save, now does NOT when invoked from a procedural save within the BeforeClose event????
Everything from workbook protecting & unprotecting to setting the visibility of sheets doesn't work.
Strangley enough, while in debug mode within the BeforeSave event, I can go to the menubar thru Tools and Unprotect (or protect) the workbook. Although once unprotected I still can't change the visibility of sheets or activate a different sheet. When I do any of these commands in the immediate window (or stepping thru my code in debug), I get no errors; they're just ignored UNTIL I crash trying to select a cell on an inactive sheet (the sheet.activate was immediately prior, but ignored????)
Sorry for the long post, but I wanted to give all the facts. I sure hope this is something simple that I'm not seeing late at night.
Thanks in advance!
TMKTECH
This code (which I'll be happy to share if needed), works fine if I do an EXPLICIT SAVE from the menu.
I also have code in the Workbook_BeforeCLOSE event that also procedurally saves the workbook (thus invoking the BeforeSave event for the "clean-up" code). THIS IS WHERE THINGS GO HAYWIRE.
The same code that worked with the explicit save, now does NOT when invoked from a procedural save within the BeforeClose event????
Everything from workbook protecting & unprotecting to setting the visibility of sheets doesn't work.
Strangley enough, while in debug mode within the BeforeSave event, I can go to the menubar thru Tools and Unprotect (or protect) the workbook. Although once unprotected I still can't change the visibility of sheets or activate a different sheet. When I do any of these commands in the immediate window (or stepping thru my code in debug), I get no errors; they're just ignored UNTIL I crash trying to select a cell on an inactive sheet (the sheet.activate was immediately prior, but ignored????)
Sorry for the long post, but I wanted to give all the facts. I sure hope this is something simple that I'm not seeing late at night.
Thanks in advance!
TMKTECH