![]() |
Programmatically Adding Code to a Workbook
Due to the attempts at programmatically adding code crashing Excel, I simply
tried: Wb.Sheets(1).EnableSelection = xlUnlockedCells AFTER the sheet had been copied into Wb. This works. Problem solved. Thanks! -- Dr. Doug Pruiett Good News Jail & Prison Ministry www.goodnewsjail.org "Chaplain Doug" wrote: Excel 2003. As I create new workbooks, I wish to place the following code into the workbook: Private Sub Workbook_Open() ThisWorkbook.Sheets(1).EnableSelection = xlUnlockedCells End Sub How can I do this programmatically? The reason I need to do this is because as I create the new workbook, I am copying in a single sheet (Sheets(1)) which is protected and which has only certin cells unlocked. I only want the user to be able to select the unlocked cells. Although the EnableSelection=xlUnlockedCells is set in the original, it does not carry over on the copy. Thus, the need for the Workbook_Open routine to reset it. Thanks for the help. -- Dr. Doug Pruiett Good News Jail & Prison Ministry www.goodnewsjail.org |
Programmatically Adding Code to a Workbook
have you tried saving, then closing the new workbook, then reopening it? Is
the restriction still in effect? -- Regards, Tom Ogilvy "Chaplain Doug" wrote: Due to the attempts at programmatically adding code crashing Excel, I simply tried: Wb.Sheets(1).EnableSelection = xlUnlockedCells AFTER the sheet had been copied into Wb. This works. Problem solved. Thanks! -- Dr. Doug Pruiett Good News Jail & Prison Ministry www.goodnewsjail.org "Chaplain Doug" wrote: Excel 2003. As I create new workbooks, I wish to place the following code into the workbook: Private Sub Workbook_Open() ThisWorkbook.Sheets(1).EnableSelection = xlUnlockedCells End Sub How can I do this programmatically? The reason I need to do this is because as I create the new workbook, I am copying in a single sheet (Sheets(1)) which is protected and which has only certin cells unlocked. I only want the user to be able to select the unlocked cells. Although the EnableSelection=xlUnlockedCells is set in the original, it does not carry over on the copy. Thus, the need for the Workbook_Open routine to reset it. Thanks for the help. -- Dr. Doug Pruiett Good News Jail & Prison Ministry www.goodnewsjail.org |
All times are GMT +1. The time now is 05:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com