If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > protect vba code

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-18-05, 06:41
miligor miligor is offline
Registered User
 
Join Date: Aug 2004
Posts: 15
Question protect vba code

Is there a way to protect vba code from viewing ?
Reply With Quote
  #2 (permalink)  
Old 01-18-05, 09:42
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
No absolute way - let's face it, if you have a computer, someone could break the security, and especially with MS Office products. However, the most common way of protecting the code (from 99% of the people who use Excel/Word) is this:

1. In VBE goto Tools | VBE Project Properties...

2. Select the Protection tab

3. Check the box for "Lock project for viewing"

4. Input and confirm your password

5. Save and close the workbook
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
  #3 (permalink)  
Old 01-18-05, 09:44
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
Oh yeah, and remember your password!
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
  #4 (permalink)  
Old 01-18-05, 10:53
cpgospi cpgospi is offline
Registered User
 
Join Date: Sep 2003
Location: MN US
Posts: 313
Quote:
Originally Posted by shades
No absolute way - let's face it, if you have a computer, someone could break the security, and especially with MS Office products. However, the most common way of protecting the code (from 99% of the people who use Excel/Word) is this:
For what it's worth, last week my boss locked himself out using this method (and forgetting his PW.) Took about 5 minutes on Google to find a utility to reset the password.
So 99% might be more like 97%
Reply With Quote
  #5 (permalink)  
Old 01-18-05, 12:34
shades shades is offline
Registered User
 
Join Date: Oct 2003
Posts: 1,091
quot et demonstratum
__________________
old, slow, and confused
but at least I'm inconsistent!

Rich
(retired Excel 2003 user, 3/28/2008)

How to ask a question on forums
Reply With Quote
  #6 (permalink)  
Old 01-18-05, 15:46
miligor miligor is offline
Registered User
 
Join Date: Aug 2004
Posts: 15
Thanks, it works
Reply With Quote
  #7 (permalink)  
Old 01-18-05, 21:41
savbill savbill is offline
Registered User
 
Join Date: Feb 2004
Posts: 533
FWIW - I like to separate my code from the data. This way I can hide the code file from view and have it open as read-only (since it is fixed code it will not be updated during use) With the file hidden it will not show in the workbooks list. I keep master copies of programs so if something gets altered I can replace it quickly.

Password protection and saving as a .xla gives more protection, but for internal stuff hiding and using read-only works good without having to keep up with passwords.

Here's utility code I use to to hide, save, and close a code file after I've finished editing and testing.

Code:
Sub CloseNhide()
    Dim visbook As Object

    Set visbook = ActiveWorkbook
    ActiveWindow.Visible = False
    visbook.Save
    visbook.Close
End Sub

/
__________________
~

Bill
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On