Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forgotten Password to Unprotect Workbook/sheet Brandon Excel Discussion (Misc queries) 10 April 4th 13 12:10 PM
I need to unprotect sheet so I cn sve it but need a password? scout ron Excel Discussion (Misc queries) 2 May 28th 10 03:05 PM
Forgot the password (to unprotect a sheet) Venkatesh V Excel Discussion (Misc queries) 1 March 29th 06 08:32 AM
how to unprotect password from VBA macros in excel starwil Excel Programming 1 May 16th 04 12:16 PM
Protect/unprotect sheet with password with VBA? dragontale[_7_] Excel Programming 1 April 19th 04 09:29 PM


All times are GMT +1. The time now is 05:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"