View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
john tempest[_2_] john tempest[_2_] is offline
external usenet poster
 
Posts: 27
Default locking vba code

this is the code i use to copy and save the worksheet,could there be a flaw
in the code
Private Sub CommandButton1_Click()
Dim wkbk As Workbook, sh As Worksheet
Worksheets("MANUAL TS").Copy
Set wkbk = ActiveWorkbook
' get rid of all cell formulas
For Each sh In wkbk.Worksheets
With sh.UsedRange
.Value = .Value
'getrid of command button'
ActiveSheet.OLEObjects("CommandButton1").Delete
'protect sheet'
ActiveWorkbook.Sheets("MANUAL TS").Protect
Password:="AABAABABBBAW"


End With
Next
wkbk.SaveAs "C:\Documents and Settings\Administrator\My
Documents\HOWDENS\TIMESHEET\ " & Sheets("MANUAL TS").Range("B5") & ".xls"
wkbk.Close
End Sub
any ideas
thankyou john tempest

"Tom Ogilvy" wrote:

Protection is done at project level - so for the whole workbook.

I have never tried it, but if your project is protected and you can copy a
sheet with code out of the workbook and the code is accessible, that sounds
like a flaw in the protection scheme. I would expect either the sheet
couldn't be copied or the code would not be copied with it.

--
Regards,
Tom Ogilvy



"john tempest" wrote in message
...
i have locked and password protected my code in a worksheet. when i remove
this worksheet from the worbook and save it the protection is not there.
can anybody help
thankyou john tempest