Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 16th, 2006, 12:51 AM
Registered User
 
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hiding a VBA Code from other users.

Hi All,

I have seen some macro run excel programs, where the users cannot see the VBA code. Even after opening the Visual basic editor and list of macros will not be visible when the user select run button of the macro.
How it is possible?

Please help me in creating a macro program like this. where i can hide my valuable code.

Thank you.
 
Old February 16th, 2006, 09:44 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 173
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Shamala,

This is really a two part question. Firstly, you can ensure that your subroutines do not show in the Macro Run dialog box by ensuring that each one requires a parameter to be passed to it. You can do this even whilst requiring an Optional parameter which then does not affect the calling of the Sub. The following code should demonstrate the point:
Code:
Sub Test()

    MsgBox "Hello"

End Sub

Sub Test2(Optional dummy As Byte)

    MsgBox "Hello2"

End Sub
To lock up the code so it can't be seen from the VBE requires you to do something else, you need to lock the project for viewing. To do this go to the VBE, select Tools -> VBAProject Properties ... from the menus (NB if you've changed the name of your project from the default of "VBAProject" to something else then the menu option will read (something else) Properties ...). This will bring up the project properties dialog box. Select the Protection tab, check the lock project for viewing checkbox, enter a password and click ok. If you save and re-open the file you will not be able to view any of the code without first entering the password.

It should be noted that whilst this password provides a level of deterant to viewing the code it is not totally secure. There are programs available for purchase that will crack the password in less than a second. If you really don't want people to steal your intellectual property then you are best off getting a copy of Visual Studio, writing your code in VB / C, compiling your code into a DLL and linking your Excel workbook to the DLL. Its a lot more work though!

Maccas

The Following User Says Thank You to maccas For This Useful Post:
Shasur (May 15th, 2011)
 
Old February 21st, 2006, 02:09 AM
Registered User
 
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Thank you very much for the valuable information.

 
Old May 6th, 2011, 04:35 PM
Authorized User
 
Join Date: Dec 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There's a handy program called "Protect VBA Code" by

dombajsoft.com

that encrypts the password so people can't crack the password and see your vba.
 
Old May 6th, 2011, 06:04 PM
Authorized User
 
Join Date: Dec 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Otherwise, there is DataSafeXL that costs...
 
Old May 15th, 2011, 04:00 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Quote:
Originally Posted by maccas View Post
Shamala,

This is really a two part question. Firstly, you can ensure that your subroutines do not show in the Macro Run dialog box by ensuring that each one requires a parameter to be passed to it. You can do this even whilst requiring an Optional parameter which then does not affect the calling of the Sub. The following code should demonstrate the point:
Code:
Sub Test()
 
    MsgBox "Hello"
 
End Sub
 
Sub Test2(Optional dummy As Byte)
 
    MsgBox "Hello2"
 
End Sub
To lock up the code so it can't be seen from the VBE requires you to do something else, you need to lock the project for viewing. To do this go to the VBE, select Tools -> VBAProject Properties ... from the menus (NB if you've changed the name of your project from the default of "VBAProject" to something else then the menu option will read (something else) Properties ...). This will bring up the project properties dialog box. Select the Protection tab, check the lock project for viewing checkbox, enter a password and click ok. If you save and re-open the file you will not be able to view any of the code without first entering the password.

It should be noted that whilst this password provides a level of deterant to viewing the code it is not totally secure. There are programs available for purchase that will crack the password in less than a second. If you really don't want people to steal your intellectual property then you are best off getting a copy of Visual Studio, writing your code in VB / C, compiling your code into a DLL and linking your Excel workbook to the DLL. Its a lot more work though!

Maccas
In addition to Maccas's solution you can either do the following

1. Write the code in a function (instead of subroutines)

Private Function Test2
...

End Function
or

2. Set the access to Private.

Private Sub Test2

End Sub

Appreciate Maccas' detailed response

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble hiding and unhiding columns in VBA jtmelb Excel VBA 0 February 14th, 2007 07:04 PM
Hiding the report from users grobbo61 Access VBA 1 June 26th, 2006 11:41 AM
Hiding VBA Code Paula222 Access VBA 3 February 11th, 2006 06:14 AM
hiding javascript code using ASP pablohoney Classic ASP Basics 2 March 30th, 2005 10:58 AM
hiding include file code isheikh BOOK: Beginning ASP 3.0 0 April 6th, 2004 01:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.