Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Unlock sheet

I've got a spreadsheet with some cells that need to be locked on it
However, I need to then unlock the sheet when a macro is run over i
which hides some columns. Is there a way to unlock a spreadsheet tha
has password protection?
When I use the command ".unlock" it comes up with a prompt for th
password. Can I somehow put that into the code?
Basically I need to unlock the sheet to run a macro, but I can't see
to totally automate it for other users as currently I get a prompt fo
the password.
Any ideas?
Thanks for your help,
Pau

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Unlock sheet

Do you mean Unprotect?
You could use:

ActiveSheet.Unprotect("yourpassword")

But then the password can be read in the module if the
project is not locked for viewing.

-----Original Message-----
I've got a spreadsheet with some cells that need to be

locked on it.
However, I need to then unlock the sheet when a macro is

run over it
which hides some columns. Is there a way to unlock a

spreadsheet that
has password protection?
When I use the command ".unlock" it comes up with a

prompt for the
password. Can I somehow put that into the code?
Basically I need to unlock the sheet to run a macro, but

I can't seem
to totally automate it for other users as currently I get

a prompt for
the password.
Any ideas?
Thanks for your help,
Paul


---
Message posted from http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Unlock sheet

just add the password part
ActiveSheet.Protect Password:="dd", DrawingObjects:=True,
Contents:=True, Scenarios:=True
ActiveSheet.Unprotect Password:="dd"
from vba HELP for password or just highliight password in the vbe and touch
F1 key
expression.Protect(Password, DrawingObjects, Contents, Scenarios,
UserInterfaceOnly, AllowFormattingCells, AllowFormattingColumns,
AllowFormattingRows, AllowInsertingColumns, AllowInsertingRows,
AllowInsertingHyperlinks, AllowDeletingColumns, AllowDeletingRows,
AllowSorting, AllowFiltering, AllowUsingPivotTables)

expression Required. An expression that returns a Worksheet object.

Password Optional Variant. A string that specifies a case-sensitive
password for the worksheet or workbook. If this argument is omitted, you can
unprotect the worksheet or workbook without using a password. Otherwise, you
must specify the password to unprotect the worksheet or workbook. If you
forget the password, you cannot unprotect the worksheet or workbook. It's a
good idea to keep a list of your passwords and their corresponding document
names in a safe place
--
Don Guillett
SalesAid Software


"PaulSin " wrote in message
...
I've got a spreadsheet with some cells that need to be locked on it.
However, I need to then unlock the sheet when a macro is run over it
which hides some columns. Is there a way to unlock a spreadsheet that
has password protection?
When I use the command ".unlock" it comes up with a prompt for the
password. Can I somehow put that into the code?
Basically I need to unlock the sheet to run a macro, but I can't seem
to totally automate it for other users as currently I get a prompt for
the password.
Any ideas?
Thanks for your help,
Paul


---
Message posted from
http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Unlock sheet

Paul

Sub SHEETPROTECT()
ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub

Sub SHEETUNPROTECT()
ActiveSheet.Unprotect Password:="justme"
End Sub

Combine the two as in........

Sub Do_Stuff()
ActiveSheet.Unprotect Password:="justme"
'your code here
ActiveSheet.Protect Password:="justme"
End Sub

Gord Dibben Excel MVP


On Tue, 22 Jun 2004 09:42:19 -0500, PaulSin
wrote:

I've got a spreadsheet with some cells that need to be locked on it.
However, I need to then unlock the sheet when a macro is run over it
which hides some columns. Is there a way to unlock a spreadsheet that
has password protection?
When I use the command ".unlock" it comes up with a prompt for the
password. Can I somehow put that into the code?
Basically I need to unlock the sheet to run a macro, but I can't seem
to totally automate it for other users as currently I get a prompt for
the password.
Any ideas?
Thanks for your help,
Paul


---
Message posted from http://www.ExcelForum.com/


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
how to unlock a sheet without password nakama Excel Discussion (Misc queries) 2 November 19th 09 02:02 PM
How to unlock an Excel sheet JeanMickey Excel Discussion (Misc queries) 2 June 16th 09 02:56 PM
Prevent User to unlock Sheet Tabs Param Excel Worksheet Functions 2 March 23rd 06 01:45 AM
how do i password protect an .xls file? how do i unlock it for automation. e.g. want to unlock and access a .xls from another .xls macro. Daniel Excel Worksheet Functions 1 June 24th 05 02:59 PM
Sheet Protection Unlock Heather Excel Worksheet Functions 2 April 25th 05 04:17 PM


All times are GMT +1. The time now is 07:30 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"