Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Protect and Lock Problem SOLVED!!

Perhaps I have been trying all wrong with this project I have asked about
before. I tried a different approach

I decided that the original form (blank fields) can be saved without macros
since I know the macro password to do things behind the scenes

I used the macro to hide the "warning sheet" that macros must be enabled and
open all others if macros were enabled, otherwise all the user sees is a big
blue screen that says "macros must be enabled to use this file properly.
Since workbook is also protected, they cannot get at other forms with
'unhide'.

code:

Private Sub Workbook_Open()
Dim wks
Application.ScreenUpdating = False
ActiveWorkbook.Unprotect password:="mypassword"
For Each wks In Me.Worksheets
wks.Visible = True
Next
Me.Worksheets("intro").Visible = False
ActiveWorkbook.Protect password:="mypassword"
Set wks = Me.Worksheets("request")

End Sub

Now instead of worrying about the file name, I simply went to the file save
event to lock things down- so as soon as someone saves a file with
information in it- critical fields are locked which prevent the user from
'recycling' the spreadsheet- which was causing a lot of problems- submitting
bad information- tis better if each user filled it out from scratch rather
than miss a fiew key fields with previous information in them. If the field
is blank to begin with, we know to kick it back as incomplete rather than to
proceed ahead with bad information... (very costly).

so for the save event:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

Sheets("Request").Range("K4") = Now 'date stamps file so user cannot
'backdate' the file and forward it.
Set wks = Me.Worksheets("request") ' sets current worksheet to first page

ActiveWorkbook.Unprotect password:="mypassword"

ActiveSheet.Unprotect password:="mypassword"
Range("B4:B9").Select 'locks the critical areas that make it a unique
record file
Selection.Locked = True
ActiveSheet.Protect password:="mypassword"
ActiveWorkbook.Protect password:="mypassword"



End Sub



Thanks to Frank, Simon and rjb for your various thoughts and techniques. By
grunting through this, I finally felt like I learned something!!!


Thanks
Paul


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
Database problem to be solved... Please help! Nick M. Excel Discussion (Misc queries) 2 September 13th 08 01:02 AM
solved problem claude Excel Worksheet Functions 1 July 7th 06 08:14 PM
Excel/MSIE problem with add-in, I can't get it solved WMB Setting up and Configuration of Excel 0 April 20th 05 06:54 PM
Excel/MSIE problem with add-in, I can't get it solved msnews.microsoft.com Excel Discussion (Misc queries) 0 April 18th 05 08:43 AM
How can the Travelling Salesman Problem be solved using Solver Ad. andrei665 Excel Discussion (Misc queries) 3 April 16th 05 04:09 AM


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