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

I know it is difficult to protect programs in excel but I would like to know if there is a way to put code in the Workbook start up module that would require a different password every 6 months to open. I thought I could have maybe 20 passwords, one for every 6 months, that would cover me for 10 years

Maybe an if Now is past a particular date require a password. Then the code would run the clock again until another 6 months expires

Any suggestions would be great

Please provide detailed code as i am a newbie

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default password protection

Bruce,

This might be a little way out but try something like:

Use a workbook close event to xlVeryHidden all but one of your worksheets.

In the workbook open macro have something like:
pswrd = InputBox("Enter Password","Password")

than use If....Then or Select Case to test for
Date < yourcutoff date
pswrd = "password"
set up conditions for all your time periods

if the test is true than unhide all the worksheets. If false close the
workbook.

This code is untested but should work. Copy and paste into the
"ThisWorkbook" Module.
Keep in mind that it can be easily defeated by a skilled Excel person.

Add additonal 'Case' statements for your time periods and input your
own 'PsWord' for each.

''''''''''''''''''''''''''''''
Option Explicit

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim x As Long
For x = 2 To ActiveWorkbook.Worksheets.Count
Sheets(x).Visible = xlVeryHidden
' hides all but the first worksheet
Next
End Sub

Private Sub Workbook_Open()
Dim pswrd As String, PsWord As String, dte As Date

' Ask user for password
pswrd = InputBox("Enter Password", "Password")
' Today's date
dte = Date

Select Case dte
Case #1/1/2004# To #12/31/2004#
PsWord = "Word for 2004"
Case #1/1/2005# To #12/31/2005#
PsWord = "Word for 2005"
End Select

If pswrd = PsWord Then
' if password is correct, unhide the worksheets
Dim x As Long
For x = 2 To ActiveWorkbook.Worksheets.Count
Sheets(x).Visible = True
Next
' if the password is incorrect, close the workbook
Else
ThisWorkbook.Saved
ThisWorkbook.Close False
End If

End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''
--
steveb
(Remove 'NOSPAM' from email address if replying direct)


"bruce forster" wrote in message
...
I know it is difficult to protect programs in excel but I would like to

know if there is a way to put code in the Workbook start up module that
would require a different password every 6 months to open. I thought I
could have maybe 20 passwords, one for every 6 months, that would cover me
for 10 years.

Maybe an if Now is past a particular date require a password. Then the

code would run the clock again until another 6 months expires.

Any suggestions would be great.

Please provide detailed code as i am a newbie.



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
Password protection in macro ( Anybody can view my password in VB Sherees Excel Discussion (Misc queries) 2 January 24th 10 10:05 PM
Excel Data Protection- AKA: Sheet/Macro Password Protection Mushman(Woof!) Setting up and Configuration of Excel 0 December 29th 09 06:50 AM
Password protection [email protected] Excel Discussion (Misc queries) 5 February 19th 08 05:13 AM
Password protection Noemi Excel Discussion (Misc queries) 2 January 24th 06 05:18 AM
Password Protection carter Excel Discussion (Misc queries) 1 February 22nd 05 09:27 PM


All times are GMT +1. The time now is 02:54 AM.

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"