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

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default locking vba code

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default locking vba code

I ran your code with the project protected for viewing in the VBE and it did
copy the worksheet and its code (the code in the sheet module) to the new
workbook and the code was able to be viewed. I guess you will have to
expand your code to strip the code in the copy. See Chip Pearson's page on
this and related topics

http://www.cpearson.com/excel/vbe.htm

--
Regards,
Tom Ogilvy


"john tempest" wrote in message
...
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






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default locking vba code

One way to work around this problem is to obfuscate (= replace with
functionally equivalant, but much harder to understand) the VBA code
within the entire Workbook. That way, even if they get at your code,
it's much harder for them to understand it.

An open source Excel/VBA source code obfuscation Add-in is available
at:

http://invisiblebasic.sourceforge.net

Just use the Add-in's "Save Invisibly As" command before sending out
your workbook.

John

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
row locking, instead of file locking? Bob W Excel Discussion (Misc queries) 2 September 7th 07 09:36 PM
locking formula in cells in without locking whole sheet SuziQ Excel Discussion (Misc queries) 1 July 21st 06 03:58 PM
Locking Code In Individual Macros Carl Bowman Excel Discussion (Misc queries) 2 May 19th 05 06:05 PM
Locking VBA code via Project properties but cannot save the workbook over itself Shane Excel Programming 4 July 27th 04 01:00 AM
Code for locking windows Dean Knox[_2_] Excel Programming 3 October 31st 03 03:56 PM


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