Protect VBA Modules & Code

May 18, 2009

I would like to protect the VBA modules I have written in a spreadsheet. Is there any way of password protecting these (as there is with Excel workbooks/worksheets) -such that users can not see the VBA code unless they enter a password?

View 4 Replies


ADVERTISEMENT

SHOW ALL CODE MODULES & SUBS IN A WORKBOOK

Jun 8, 2007

A recent message prompted me to complete a project to show all modules and subroutines in a workbook.

As use of VBA to manipulate the VB Editor is a recurring issue I thought it a good idea to share this.

Option Base 1
Dim WBname As String
Dim ws As Worksheet
Dim TitleStr As Variant
Dim VBProject As Object
Dim ToRow As Long
Dim ToCol As Integer
Dim ComponentType
Dim MyComponent As Object
Dim ComponentName As String
Dim TypeArray As Variant
Dim StdCol As Integer
Dim LastLine As Long
Dim CurrentLineNumber As Long
Dim CurrentLineText As String
Sub SHOW_ALL_MODULES()
WBname = ActiveWorkbook.FullName
On Error Resume Next
Set ws = ActiveWorkbook.Worksheets("WB Contents")
If Err.Number 0 Then ' sheet not exist....................

View 2 Replies View Related

Class Modules: Provide Users With In-Code List Of Constants

Jul 8, 2009

I am working with a class module and some fields require specific inputs that another coder may not intuitively know. How can I create a list of acceptable conastants that will appear as a drop down when the user is coding with the custom object?

For example:
I am creating an Email Engine object that will handle all my emailing needs in code, because coding emails is such a pain. Then I can just create the blasted thing, import the class module where needed and never have to worry about it again. Some coworkers are interested in using the module for their projects when I am finished. I want to put an option for message flags in the object, but only certain colored flags are allowed. How can I get the VBE to show a little drop down with the acceptable flag constants when another user types

[Object Variable].MessageFlagColor = {drop down list of options}
I started with

Public Property Let MessageFlagColor(Value As Constants)

End Property
But that hasn't gotten me anywhere.

View 9 Replies View Related

Code To Protect Formulas

Dec 8, 2008

is there any hard code out there that protects formulas in a cell

i have a sheet with formulas down a column
that used once disappear
is there any way to code this so they are always there?

View 11 Replies View Related

Protect VBE Project Using Code

Mar 31, 2009

Is there a way to protect a VBE project using a macro instead of going to the properties and manually typing in a password? I'm using a macro that emails just one worksheet in my workbook (creates a new temp file, emails, and deletes it) but when the new file gets to the recipient the VBE project is unlocked.

I found a way to protect the worksheet before saving the temp file, so the worksheet is protected as it should be, but the project explorer window is completely open. Then anybody can see the passwords I'm using to protect the sheet in the first place. So I need to somehow re-protect the project before it saves and emails.

View 4 Replies View Related

Protect Part Of The VBA Code

Aug 4, 2006

I understand that we can protect the VBA coding through check the "Lock project from viewing in the Tools>VBAProject Properties. However I'll still need to open some of the code for other users to customize the program while some of the important code are protected.

View 7 Replies View Related

VBA Code Not Working When I Protect The Sheet

Nov 9, 2008

I have used the below code to make hide/unhide some columns in my excel sheet. It works fine. Now, I need to protrect the sheet except the coloured cells. So I unlocked the cell by clicking the property of the colored cells & then did this :- tools- protection-Protect sheet - protect unlocked cells. But after protecting this sheet the macro code of hiding/unhiding of the columns are NOT WORKING & Errors is coming. I have used the below code:-

View 4 Replies View Related

Protect Source Code From User

Aug 26, 2009

how to protect source code from user or give the password when the user view code, right click on a sheet.

View 4 Replies View Related

Protect And Unprotect Workbook Using VBA Code

Oct 31, 2011

i'm looking for a vba code to solve the following problem a .xlsm workbook, the protect workbook passwork is known as "111111", the VBA project password is "222222", and how to write vba code to insert a new sheet, suppose the workbook has three worksheet, now using vba code to unprotect workbook, and auto insert a newsheet, then protect workbook again, whcih the password remains as "111111" using a commondbutton to do this, everytime you click, insert a new sheet.

View 9 Replies View Related

VBA Code To Password Protect Workbook

Aug 14, 2008

I am trying to add a command button that will set a custom view, password protect all worksheets, and finally password protect the entire workbook structure. The code I am using will correctly set the view and add the password to the worksheets, but it will not apply the password to the workbook structure. What do I need to add?

Private Sub cmdReset_Click()

ActiveWorkbook.Unprotect Password:="test"
ActiveWorkbook.CustomViews("Sales").Show
ActiveWorkbook.Protect Password:="test"
ActiveSheet.Unprotect Password:="test"

Sheets("Accessories").Select
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False
ActiveSheet.Protect Password:="test"

View 7 Replies View Related

Hide / Protect Worksheet Code

Jul 9, 2007

I need to be able to save a copy of my spreadsheet but protect the structure so that the hidden rows cannot be opened by the person that I e-mail it to. At the moment I am using the current

Private Sub CommandButton2_Click()
Do
fName = Application.GetSaveAsFilename
Loop Until fName <> False
ActiveWorkbook.SaveAs Filename:=fName
Call ProtectRobin
End Sub
Private Sub ProtectRobin()
ActiveWorkbook.Protect ("Robin")
End Sub

The saving part of the macro is working perfectly, however I cannot get the protection to work. It must have a password - I do not want the receipient to be able to go 'Tools' > 'Unprotect Sheet'.

View 6 Replies View Related

Code To Protect And Unprotect Cell Ranges?

Jan 28, 2014

following code so as to have certain cell ranges protected and unprotected USING COMMANDBUTTON/PASSWORD

Code:
Private Sub CommandButton1_Click()
Dim Password As String
JamesPassword = "MyPassword" '

[Code]......

View 8 Replies View Related

Protect Sheet But Allow Macro Code To Modify

May 24, 2008

I am trying to design a tool which dynamically results in different cells depending on users inputs. Yet, I am willing to protect most of the cells to avoid any user involuntarily (or voluntarily!) modifying the formulas/contents of the calculated (and locked) cells. Is there any way to protect my sheets, allowing only a certain macro to modify the locked and protected cells?

View 4 Replies View Related

Rewrite Protect Code So That It Will Work With A Hidden Sheet.

Aug 25, 2009

I need this code below to work in a macro on a hidden sheet.. FYI the sheet name is "Closed".

View 2 Replies View Related

Code To UNPROTECT Then PROTECT Workbook When Macro Runs

Jul 24, 2014

Okay, I have this code and it works very well - but it only works if my WORKBOOK is unprotected. I know how to Unprotect then Protect an ActiveSheet, but I can't figure out how to Unprotect then Protect my workbook when the macro runs..

Sub BLM_RENAME_SHEET()
Dim WS As Worksheet
Application.ScreenUpdating = False
For Each WS In ActiveWindow.SelectedSheets

[Code] ......

View 9 Replies View Related

Hide And Password Protect The VBA Code So That They Can't Just Change The Pictures Visible Section To True

Nov 7, 2008

I've used VBA to make a picture appear when all the correct answers have been entered and it all works well. However, not to be too mean to 15 year olds, many of my students can be devious little feckers, and I want to hide and password protect the VBA code so that they can't just change the pictures visible section to true. I can password protect the workbook and worksheet, but not the VBA.

I'm entering the Visual Basic editor and I can see my simple script. I then click Tools - VBproject properties - protection. I'm clicking the "Lock Project for Viewing" box then filling in the password and confirming the password and clicking OK. But I can still see and edit my script, despite protecting the sheet and workbook.

View 3 Replies View Related

Password Protect Columns - Hide And Protect Ability To Unhide

Jan 17, 2013

Some sensitive data is held on worksheets that are used by people that do not have access to see the data.

It would be most convenient to keep the data in these worksheets but hide it from view of the users.

Is there a way to password protect a users ability to unhide a column?

View 2 Replies View Related

Password Protect: Unlock The Worksheet, Autofilter It, Print It, Unfilter It, And Password Protect The Sheet Again?

Jan 12, 2007

I have a sheet that is password protected. I have this code attached to a command button. It will unlock the worksheet, autofilter it, print it, unfilter it, and password protect the sheet again. However it is protecting it without a password. I need to have it protected with the password so that someone will not be able to just go to tools to unprotect the sheet.

Private Sub CommandButton1_Click()
ActiveSheet.Unprotect "rainforest"
Columns("O:O").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=">0", Operator:=xlAnd
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Selection.AutoFilter Field:=1
Selection.AutoFilter
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
End Sub

View 3 Replies View Related

Modules In VBA

Feb 26, 2009

Can i know how many modules can be used in a VBA Program

View 9 Replies View Related

Class Modules?

Oct 14, 2008

I'm wondering about class modules and what they can be used for etc etc? i want to continue developing my VBA and feel that this area is the next step?

View 2 Replies View Related

Ignoring 1 Of Two Modules

Jan 28, 2010

I have managed to get it almost done with lots of help from here the last issue I have is this:

The module I want transferred is working the assigning of the macro within that module to the button is working, however, when it gets to the FillSalesSheet section it opens the said workbook but then jumps to the module and the FillSalesSheet in that.

Module 1 which I would like ignored on the newly formed workbooks looks like this: ...

View 14 Replies View Related

Removing Modules

Nov 16, 2006

It seems like I am asking a question at least once a day. I searched the net and forums and could not find an answer to this question. Thanks to everyone for the help I am making a lot of progress because all of you. Basically, I have a read-only workbook which the user gets a prompt to save as a new workbook for editing purposes. I have a autorun macro so now when the user opens their workbook, it contains my autorun macro. I do not want this. Is there a way to remove modules so that the users copy has no macro information?

View 9 Replies View Related

On Open Run Two Modules

Apr 16, 2008

I have two modules I wish to run when I open a workbook. The reason I have them as modules is they are required to be run manually, also.

Is it possible for me to set a Workbook_Open() sub that will run these two modules?

The modules names are Module1 and Module2.
The modules stipulate what sheets etc they have to act on, I only need the modules to be initiated.

View 9 Replies View Related

Web Queries In Modules

Aug 8, 2006

I'm trying to produce a spreadsheet that pulls infomation from different web pages throughout the day. It needs to pull quite a large amount of information from different web pages hence I wanted to produce a subroutine which could be called with different variables for each web page, i.e. url, field, destination, etc.

To actually produce the query I recorded a macro and then used the code it produced. I then changed the URL to url, a string variable which holds the urls of the pages. The destion address was changed to destination, a range variable to store the destionation location, and the webTable was changed to table also a string variable to store the table number. This is shown below.

With ActiveSheet.QueryTables.Add(Connection:= _
url, Destination:= destination)
.Name = "q?s=%5EFTSE&m=L_137"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True.............................

View 2 Replies View Related

Export All Modules

Feb 11, 2008

I had a search and look around, but couldn't find any information on how to quickly (automatedly) export all the modules in a workbook to text files.

View 3 Replies View Related

Delete All Modules

Apr 17, 2008

I was looking for code that actually deletes ALL modules in the VBA code after I terminate a particular program.

View 2 Replies View Related

Keeping Last Row Variable Across Modules?

Jun 11, 2014

I'm trying to make it so that a lastrow I defined in one module will still be defined in another macro.

My background for this - my macro is too large for one module, therefore, I split it in two. However, the new module uses defined variables (multiple lastrow definitions) from the original module.

So, is there a way to make it so when I originally define a lastrow in one module, other modules will recognize it?

View 8 Replies View Related

Call Modules From Array?

Sep 14, 2012

I have a number of modules that I want to call is it possible to call them from an array

For example

myarray = Array("Outstanding_Per_Agent", "Unique_Records")

Call myarray

This doesn't work as it says it expects a sub function or property

Do I need to define "myarray" as something or is it even possible.

View 2 Replies View Related

How To Dim A Response (from Input Box) Throughout Different Modules

Jan 21, 2014

I'm working with a substantial amount of code (which, due to its size, has been spread out into different modules). Whenever I transition from one module to the other, I have placed a msg at the beginning of each module to prompt the user to simply insert an integer to signify which version of the automation that is run. The following is an excerpt of a sample msg

[CODE]
Dim Msg, Title As String
Dim MyInput As Integer
' Define message."

[Code].....

Where, whatever report is being run, will be the same throughout all of the modules (for example, if you run the "Day" Report" at the beginning, the rest of the automation should be run using the "Day Report" code, not the "Night Report").

Is there a way to do one of the following

1. Label the input of "Day Report" or "Night Report" at the beginning of the automation (where the above except of code is how that would be done), and that can then be the determinant through the rest of the modules

2. Set my code in a specific module to, when it completes, automatically go to the same style of report (Day or Night) in the next module.

View 1 Replies View Related

Running Modules Together On Same Worksheet

May 25, 2014

Can you run 2 modules at the same time on the same worksheet.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved