Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default "How do I un/protect sheet by macro program with password

I need to input data only by macro programming.
Data sheet must be protected and only macro can unprotect to write data entry.
Then macro protects data sheet again to avoid any change.

I already try to protect with menu:
Tools Protection Protect sheet

But macro cannot remember the password.
Password is now always blank, which means can be unprotected by anybody.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default "How do I un/protect sheet by macro program with password

On Sep 19, 11:10 pm, Maruza wrote:
I need to input data only by macro programming.
Data sheet must be protected and only macro can unprotect to write data entry.
Then macro protects data sheet again to avoid any change.

I already try to protect with menu:
Tools Protection Protect sheet

But macro cannot remember the password.
Password is now always blank, which means can be unprotected by anybody.


To unprotect the sheet:
Sheets("Sheet2").Unprotect Password:="YourPassword"

To protect the sheet:
Sheets("Sheet2").Protect Password:="YourPassword"

To run a check and proceed accordingly:
Sub thiser()
Dim pw As String
pw = "YourPassword"
With Sheets("Sheet2")
If .ProtectContents = True Then
.Unprotect Password:=pw
Else
.Protect Password:=pw
End If
End With
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
AR AR is offline
external usenet poster
 
Posts: 13
Default "How do I un/protect sheet by macro program with password

The code given below will make it easy for anyone to learn the password if
they look in the code.

You can restrict access to your VB code by going to your project properties
(right click on your project in the project explorer window). Navigate to the
Protection tab and check the Lock project for viewing option. Enter a
password.

Anyone trying to access the VB code will require this password.

--
Amrit


"JW" wrote:

On Sep 19, 11:10 pm, Maruza wrote:
I need to input data only by macro programming.
Data sheet must be protected and only macro can unprotect to write data entry.
Then macro protects data sheet again to avoid any change.

I already try to protect with menu:
Tools Protection Protect sheet

But macro cannot remember the password.
Password is now always blank, which means can be unprotected by anybody.


To unprotect the sheet:
Sheets("Sheet2").Unprotect Password:="YourPassword"

To protect the sheet:
Sheets("Sheet2").Protect Password:="YourPassword"

To run a check and proceed accordingly:
Sub thiser()
Dim pw As String
pw = "YourPassword"
With Sheets("Sheet2")
If .ProtectContents = True Then
.Unprotect Password:=pw
Else
.Protect Password:=pw
End If
End With
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 638
Default "How do I un/protect sheet by macro program with password

On Sep 20, 4:48 am, AR wrote:
The code given below will make it easy for anyone to learn the password if
they look in the code.

You can restrict access to your VB code by going to your project properties
(right click on your project in the project explorer window). Navigate to the
Protection tab and check the Lock project for viewing option. Enter a
password.

Anyone trying to access the VB code will require this password.

--
Amrit

"JW" wrote:
On Sep 19, 11:10 pm, Maruza wrote:
I need to input data only by macro programming.
Data sheet must be protected and only macro can unprotect to write data entry.
Then macro protects data sheet again to avoid any change.


I already try to protect with menu:
Tools Protection Protect sheet


But macro cannot remember the password.
Password is now always blank, which means can be unprotected by anybody.


To unprotect the sheet:
Sheets("Sheet2").Unprotect Password:="YourPassword"


To protect the sheet:
Sheets("Sheet2").Protect Password:="YourPassword"


To run a check and proceed accordingly:
Sub thiser()
Dim pw As String
pw = "YourPassword"
With Sheets("Sheet2")
If .ProtectContents = True Then
.Unprotect Password:=pw
Else
.Protect Password:=pw
End If
End With
End Sub


True, very true. It is always best to lock down VBA code IMO.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default "How do I un/protect sheet by macro program with password

Note that project protection is easily bypassed by techniques reely
available to anyone who has the ability to find these groups...



In article ,
AR wrote:

Anyone trying to access the VB code will require this password.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default "How do I un/protect sheet by macro program with password

tks a lot guys

"JW" wrote:

On Sep 20, 4:48 am, AR wrote:
The code given below will make it easy for anyone to learn the password if
they look in the code.

You can restrict access to your VB code by going to your project properties
(right click on your project in the project explorer window). Navigate to the
Protection tab and check the Lock project for viewing option. Enter a
password.

Anyone trying to access the VB code will require this password.

--
Amrit

"JW" wrote:
On Sep 19, 11:10 pm, Maruza wrote:
I need to input data only by macro programming.
Data sheet must be protected and only macro can unprotect to write data entry.
Then macro protects data sheet again to avoid any change.


I already try to protect with menu:
Tools Protection Protect sheet


But macro cannot remember the password.
Password is now always blank, which means can be unprotected by anybody.


To unprotect the sheet:
Sheets("Sheet2").Unprotect Password:="YourPassword"


To protect the sheet:
Sheets("Sheet2").Protect Password:="YourPassword"


To run a check and proceed accordingly:
Sub thiser()
Dim pw As String
pw = "YourPassword"
With Sheets("Sheet2")
If .ProtectContents = True Then
.Unprotect Password:=pw
Else
.Protect Password:=pw
End If
End With
End Sub


True, very true. It is always best to lock down VBA code IMO.


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
Macro to re-protect sheet w/ original password after pasting valuesin new book [email protected] Excel Worksheet Functions 1 June 4th 08 04:27 PM
Code to protect/unprotect a sheet using a macro with password FredH Excel Discussion (Misc queries) 5 October 23rd 07 04:49 PM
How to crack "Protect Sheet" Password in Excel? Hardik Shah[_2_] Excel Programming 4 May 15th 05 02:23 PM
no password carryover with "protect sheet" in macro Trevor Shuttleworth Excel Programming 0 February 12th 04 09:44 PM
protect sheet macro - can't have it enter password inaz Excel Programming 4 January 14th 04 04:52 AM


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