Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unprotect Sheet Password in Macros
Hi:
I have an Excel file that has been used as a template to create 800+ files that has the protection worksheet applied. I now what to add more formulas to this file and want to use a macro to do it. How can I enter the unprotect password automaticcaly as part of the macro and then protect the sheet again before saving and closing? Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unprotect Sheet Password in Macros
public const MYPASSWORD as string = "supersecret" 'At the top of a module
Sub Stuff() sheets("Sheet1").unprotect MYPASSWORD 'Do your stuff sheets("Sheet1").protect MYPASSWORD End Sub -- HTH... Jim Thomlinson "Theresa" wrote: Hi: I have an Excel file that has been used as a template to create 800+ files that has the protection worksheet applied. I now what to add more formulas to this file and want to use a macro to do it. How can I enter the unprotect password automaticcaly as part of the macro and then protect the sheet again before saving and closing? Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unprotect Sheet Password in Macros
To unprotect a worksheet, assuming the book is already open:
Dim Wsh as worksheet set wsh= activeworkbook.Worksheets(1) 'Eg: for 1 sheet of active book wsh.unprotect "your_password" '... do what you have to do here 'then reprotect with wsh.protect ..... (If you meant to unprotect a protected vba project, not the sheet, then it is not possible through code) -- Regards, Sébastien <http://www.ondemandanalysis.com "Theresa" wrote: Hi: I have an Excel file that has been used as a template to create 800+ files that has the protection worksheet applied. I now what to add more formulas to this file and want to use a macro to do it. How can I enter the unprotect password automaticcaly as part of the macro and then protect the sheet again before saving and closing? Thanks |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unprotect Sheet Password in Macros
Activesheet.Unprotect Password:="ABC"
ActiveSheet.Protect Password:="ABC" ActiveWorkbook.Close Savechanges:=True -- Regards, Tom Ogilvy "Theresa" wrote in message ... Hi: I have an Excel file that has been used as a template to create 800+ files that has the protection worksheet applied. I now what to add more formulas to this file and want to use a macro to do it. How can I enter the unprotect password automaticcaly as part of the macro and then protect the sheet again before saving and closing? Thanks |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Unprotect Sheet Password in Macros
Sir,
I have a web site showing stock prices. By marking the rows and linking to excel comand, sheet1 is linked and the data changing in the web is reflected in sheet1. the problem is that in Worksheet_Change sub is not getting activated although if I key in a number tha event is happening. any help. code bellow Private Sub Worksheet_Change(ByVal Target As Excel.Range) k = 1 Application.EnableEvents = False SheetName = Worksheets("Sheet1").Cells(Target.Row, 2) Do While Worksheets("Sheet1").Cells(Target.Row, k) < "" Worksheets(SheetName).Cells(SheetsLastRow(Target.R ow), k) = Worksheets("Sheet1").Cells(Target.Row, k) k = k + 1 Loop Worksheets(SheetName).Cells(SheetsLastRow(Target.R ow), k) = Time If Target.Column = 3 Then Call CheckThePrice(Target.Row) End If SheetsLastRow(Target.Row) = SheetsLastRow(Target.Row) + 1 Application.EnableEvents = True End Sub this code does what is suppose to do if manualy we chang the cell value then hit enter. but not when the value is changed by link to the web site. please email me. thank you. "sebastienm" wrote: To unprotect a worksheet, assuming the book is already open: Dim Wsh as worksheet set wsh= activeworkbook.Worksheets(1) 'Eg: for 1 sheet of active book wsh.unprotect "your_password" '... do what you have to do here 'then reprotect with wsh.protect ..... (If you meant to unprotect a protected vba project, not the sheet, then it is not possible through code) -- Regards, Sébastien <http://www.ondemandanalysis.com "Theresa" wrote: Hi: I have an Excel file that has been used as a template to create 800+ files that has the protection worksheet applied. I now what to add more formulas to this file and want to use a macro to do it. How can I enter the unprotect password automaticcaly as part of the macro and then protect the sheet again before saving and closing? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Forgotten Password to Unprotect Workbook/sheet | Excel Discussion (Misc queries) | |||
I need to unprotect sheet so I cn sve it but need a password? | Excel Discussion (Misc queries) | |||
Forgot the password (to unprotect a sheet) | Excel Discussion (Misc queries) | |||
how to unprotect password from VBA macros in excel | Excel Programming | |||
Protect/unprotect sheet with password with VBA? | Excel Programming |