Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic


I have a model that runs perfectly in excel 2000 but gives me fits in excel 2003. Basically I have a protected input sheet with several macro buttons the user may execute. In excel 2000 the macro code executes fine using the line "Protect.UserInterfaceOnly:=True". When I try to run the same macros in excel 2003 the user is prompted for a password to unprotect the sheet before the code will execute. What is even more curious is that it only does this the first time a macro is executed. subsequent executions work fine. I would prefer not to give out the password to the users of excel 2003 but I've had no choice thus far.

Anyone have any idea how to fix this in excel 2003?


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Protect Sheet : UserInterfaceOnly

in excel 2003 i have tried experimenting with the protect method and userinterfaceonly:= true
i need macros to run but i want sheets protected (to protect formula cells etc) but still allow selection of some unlocked cells for data entry
I tried also using EnableSelection = xlUnlockedCells
i was trying to do all of this using the following code:

Code:Private Sub Workbook_Open()
Dim wSheet As Worksheet

         For Each wSheet In Worksheets
        wSheet.EnableSelection = xlUnlockedCells
        wSheet.Protect Password:="Secret", _
Next wSheet
End Sub

I have a "menu" sheet with command buttons. each button corresponds to a different sheet and different target cells on a sheet. the command button click events will activate a worksheet and hide a selection of rows at the same time. (this is for security, each sheet is restricted to specific userId's)

firstly, i dont know if this is really the right way to go about but i want this "enable selection" property to apply to all of the worksheets.
now, if i use this (i know enable selection might be recorded incorrectly here but i did get it to work some way just cant remember how)
then my macros will run and when i go to my first sheet (using a command button click event) i can select only unlocked cells but then if i select a hyperlink that takes me to the "menu" sheet that I have i get a code error because my macro on "Worksheet Deactivate" events is supposed to "Rows.Hidden = False"
and it says there is an error with the Hidden Property - in other words the macro has stopped running

what can i do??

Edited by - jonnysx on 10/12/2007 6:06:17 PM

I have a mastermacro that calls 4 other macros in succession.


Public Sub mastermacro ()
Call clearoldranges 'clear worksheets of previous data
Call protectallws
Call listof
Call getdata 'Gets data for the current period

End Sub
If I comment out call protectallws the macro works fine. However, when I allow protectallws to run I get an error message for the line

ActiveWorkbook.XmlMaps("thiscr_Map").Import URL:=scr
which is in one of the macros. I believe the error is because the worksheet is protected. However, why would I get an error if I am using the userinterfaceonly option as you can see in the protectallws macro below. The error is run time error 1004 application defined or object defined error.

Public Sub protectallws()
Dim ws As Worksheet
For Each ws In Worksheets
ws.Protect userinterfaceonly:=True


End Sub

I have a macro that executes changes in protected cells and I use the line: Sheets("SheetName").Protect UserInterfaceOnly:=True and it has always worked fine. However, a user running the model in office 2003 on Windows xp is experiencing problems. Apparently when he executes the macro he gets the "unprotect" prompt asking for the password but there is no code that specifically unprotects the sheet. Does anyone know what is going on here and how I can fix it? Also, searching the forum, I've seen the same line of code as above with "vbTrue" instead of just "True". Is there a difference?


Workbook Protection W/ UserInterfaceOnly?
I know it's possible to protect worksheets with UserInterfaceOnly:=True to allow macros to modify locked cells.

I have both visible and hidden worksheets in my workbook and I'm trying to delete some rows in two sheets simultaneously. One of the sheets is visible and the other is hidden. I'm using the following code:

Rows(intStartRow & ":" & intEndRow).Select
Sheets(Array(1, 2)).Select
Selection.Delete Shift:=xlUp

It works fine if the workbook is unprotected but returns an error if the workbook is protected. I was wondering if the workbook could be protected like worksheets?

"Workbook.protect PASSWORD:=PWORD, UserInterfaceOnly:=True" did not work.

Or is the only possible solution just unprotect the workbook in the code before selecting sheets and protect again after deletin those rows?

Could I Declare And Use Sth Like This (true, True, False)?
I know in jave I can set an array like

a [0, 0, 0, 0, 1, 2] or [true, true, false]

Could I do sth like this in vb6? use loop to set and read a long array is a little tedious, could some one give me some instructions? thx


Problem In Drag And Drop From One True DB Grid To Another True DB Grid In VB6
I' m designing a form, which contain two true DB Grid controls. I want to drag the contanets of one Grid on other Grid.any one can help ..................

Could I Use Sth Like This [true, True, False] ?
I know in jave I can set an array like

a [0, 0, 0, 0, 1, 2] or [true, true, false]

Could I do sth like this in vb6? use loop to set and read a long array is a little tedious, could some one give me some instructions? thx


Double * Double Returning 'True' And 'True'
I'm working on a calculator for an application I'm building, and with my multiplying I end up getting 'True' and 'True' trying to set a variable with multiplied values... The code I'm using at the moment is this:

Public Sub Calc_Times()
If Active = True Then Active = False Else Active = True

If Not frmPrm.clcText.Text = "" Then
dVar(i) = frmPrm.clcText.Text
frmPrm.clcText.Text = ""
i = i + 1
End If

If i > 1 Then
Dim z
z = 0
Dim x
x = 0
Addup = 0

MsgBox Addup = CDbl(Addup) * dVar(i) ' Generally remove msgbox
' its there to determine value
z = z + 1
Loop Until z = i

End If
frmPrm.clcText.Text = Addup
NeedsClear = True
End Sub

Addup and dVar() are both declared as public doubles (this is in a bas). I kind of feel stupid not being able to figure out why my multiplication won't work, but... yeah... Any help is appreciated.

Protect One Row
I have a worksheet with some command buttons in row one. I want to make the sheet function mostly normally, except that users cannot change that row, only push the buttons. I have the buttons set not to move or resize and I have row 1 locked. The worksheet is protected and I am allowing users to change everything except locked cells. Everything is unlocked except row 1. Everything seems to be fine, except that the users can still resize row 1. Is there any way to make row 1 just a static, untouchable row?


How Do I Protect My Dll ?
Hi there.

I have never compiled a Dll for redistribution in VB where the dll required a license key.
I have created many ActiveX controls this way -- and now, I need to protect my dll as it needs to be distributed to end user machines.

Can anyone tell me how it is done, as the "Require License Key" option is disabled when I try to change it in the project Properties screen.

The project consists of only one class


Protect App
As you may know, some of us use something like **** scramble for security reason then we are in trouble.

I hope that it's clear enought , thnaks guys

How To Protect Exe?
hello, how to protect a exe file?

let say the exe contains

Text1.Text = "YOUR NAME"

you compiled it in .exe

and then open the .exe into Hex Workshop

u will see the YOUR NAME in the Hex workshop

how to prevent this? i don't want to show the YOUR NAME in hex


Protect Exe?
Can anybody tell me if it is possible to prevent a vb
executable file from being moved or deleted or otherwise interfered with.(access denied kind of thing!)

VB6 .exe To Protect....

I have an aplication developed in VB6, I want to protect the Distribution CD against copy or some way to avoid unwanted distribution. Does anybody help me? .
Thanks in advance
Fernando Oviedo

VB6 Exe To Protect
I have an aplication developed in VB6, I want to protect the Distribution CD against copy or some way to avoid unwanted distribution. Does anybody help me? .
Thanks in advance
Fernando Oviedo

How Do I Protect My Dll ?
Hi there.

I have never compiled a Dll for redistribution in VB where the dll required a license key.
I have created many ActiveX controls this way -- and now, I need to protect my dll as it needs to be distributed to end user machines.

Can anyone tell me how it is done, as the "Require License Key" option is disabled when I try to change it in the project Properties screen.

The project consists of only one class


How Do You Protect Files
i have been coding a RPG and when they save the game it copys the xp to a text document , you see people can edit that how do i stop them?

Protect VBA Project
I am creating a new workbook and adding forms and modules dynamically through VB. How can I lock the VBA Project at run time with VB?

Protect Combobox
sorry but I'm new on VBA.
I'have a question how could I protect a combobox, I mean how could do not let users write inside a combobox?
thanks a lot


Sheets.protect ????

At work i am making a protected sheet, i use some macro's on the sheet, but if i protect the sheet, the macro's will not work

normally this is no problem, just tell the macro to unprotect the sheet.
But i entered a password when i protected the sheet, and now the macro's can not unprotect the sheet annymore, how can i change my macro to be able to unprotect the sheet and still protect my sheet with a password??

Please help

Copy Protect?
is there anyway to copy protect a excel document?

How To Protect A Worksheet
i'm having problems protecting a worksheet,
what i want is to protect the worksheet but what happens is
some cells are protected while others are not...
please tell me what's wrong... here is my code....

Worksheets(intt_sheetCount).Protect Password:="CANcan", DrawingObjects:=True, Contents:=True,

thanks in advance....

Workbook Won't Protect
The following is in the "Open" event for this workbook and yet when I open... I find that...sometimes it's protected...and sometimes it's not??

Application.ActiveWorkbook.Protect Password:="XXXXXXXX"

Any Idea's?


Protect Code?
Is it possible to lock/protect the macro, such that user cannot edit it?

I need to program a macro and then send a copy of the excel sheet to different users for their input. I dont want them to make any changes to the macro. Can it be done?


How To Protect A Sheet...
...disabling the Sheet1.Protect "password"[/code] the "Select locked cells" and "Select Unlocked cells" properties (disabling their checkboxes).

All I've figured out is:

Sheet1.Protect "password"

Sheet1.Unprotect "password"

Although this works fine it doesn´t change the "Select locked cells" and "Select Unlocked cells" properties as I need to.
Any thoughts on this? Thanks!

Can I Protect My Formulas PLEASE HELP!!!
can i protect my formulas in an expense report that I made in excel. So that when my reps enter numbers in the data boxes and mess up, back space to fix there number and completely erase the formula. Is there a way to protect these formulas from being erased when they back space out a number and keep erasing the formula. IHAVE BEEN WORKING ON THIS FOR 5 HOURS STRAIGHT!!!!1 PLEASE HELP!!!! thanks

Copy Protect An App In VB6..
Has any1 ever copy protected an app using VB6 ???
(By "copy protect" I just mean make it impossible or difficult for a user to just install & run your app on another PC, other than his own.)
Is there any good VB code to create CD keys from a PC serial number?
If so, how do you read the pc sn ?
Any help at all would help.. thanx..

Copy Protect An Exe
Edit by herilane: Split from very old thread

In the future, please start a new thread if you want to ask a question, and link to the old thread if necessary.
Hi behnood ,

I'm very happy to see your question because I'm facing the same problem , I'm working on a Copy Protection project and I made a DLL file so the programmer can use it in their application to check the protection .. But I need to add the protection to any EXE file .. and this will be more easier to apply .

So, I encrypt the EXE that I want to protect and I need my program to decrypt it into memory and run it from their and not from the disk so it will be more safty ... and here I STOPED !!

I need your HELP if you got any answers that will HELP ..
Please reply to me as soon as possible


Protect Processes
I want to protect a process from being closed or editted by any other. I have found a similar program to what I want here, but I just want to protect one .exe file. Is this possible in Visual Basic?

Thanks in advance,

Password Protect
Does anyone know how to make a 'Simple' Login form for VB6?

Form1(Login Area) ---Links to-->> Form2 (Only if Login info matchs a .ini file or something...


Anyways To Protect EXE From Being Decompiled?
As above.

I know decompilers are available to decompile VB compiled EXEs. Anyway to protect it from being decompiled?

Please advise.

Thank you.

Shell To Protect From C:\
Incase the name doesn't give it away, I need the code so that you may do a shell App.path & "lah.exe", vbNormalFocus
I need it however to block from something like C:\ incase it is in the direct drive of the computer

Write Protect
Hi everybody...
I've a problem to tell VB while doing backup to drive A where the disk is in write protect situation. What is the error number for "write protect disket in drive A".

Please help!...

Password Protect
Hi i'm looking to password protect a from on a page, I want a command button that can be pressed and then a password is required but i ahve no idea how to do this - can anyone help?

Password Protect
If i want to password protect my prog how would i go about that?
Like if as soon as you click on the .exe after its fineshed it would prompt you to enter a password to be able to get in, and the prog would not display without the correct pass.

Protect My Program
how can i protect my program against copy ??
is there a general code to protect vb programs against copyes ??
i want to install my program on a computer and be sure that my program will no be copyed to another computer!

thanks for help,

What Is The Best Way To Protect Data ...
Hi i am looking for a way to protect data from users... so it can only be viewed trhough the program .

I am making a program that uses an access database.

What is better ... use acces sistem to protect data or encrypt this data yourself using any code made with vb???

Protect A Database?
Ok here's the thing. My program comes with an access database that I access with ado
Here's the connection string I use (working fine)

strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strPath & "" & comTableSet.List(comTableSet.ListIndex)
dbs.Open strConn
Now my question is, is there a way that I can "protect" the database so people can't edit it with access or any other way except with my program ?( I know there is a way to put a password on an access DB, but not sure how this will affect the connection string etc..)
Any suggestion is welcomed...!

Access DB Protect
Good day

Anybody has a quick, easy and efficient way to protect an Access DB, other than with the easily crackable password ?

Or any way to find out if the user tried to open the db ?

Many thanks

How To Protect Exe From Decompilers?
hello frds,

today one of my friends told me that he can easily crack my .exe,.dll and .ocx with the help of one decompiler program. if it is true then how to Protect exe's from these type of decompilers. or what type of changes i should make in coding so that no body can read or understand my program easily.

Pls suggest me........

How To Protect A Flexgrid?
My project has an msFlexGrid, in which a user can both display and edit data. I'm modifiying the project so that in certain situations, the msFlexGrid will only allow data to be viewed and not edited.

My question is: How do I protect the fexgrid so the user can only read data?
I tried "enable = false" but that didn't seem to work.

It's Friday and I'm suffering from brainmelt.... any help is most welcome!

Protect Files
I want to write a program that encrypts all type of files including binary(exe, dll, and so on). Of course, it has to successfully decrypts files back to normal.

Can someone point me in the right direction or give me a sample?

Thank You

Added green "resolved" checkmark - Hack

Password Protect?
Hi.. I want to password protect my program, because it is a beta and I want it to be safe in case it gets leaked. Is it possible to download a encrypted password off a server or something, then not be able to load the program unless the password matches? I'm afraid someone could just load it in assembly and force it to load otherwise, so what is the best FREE method of garunteed protection?

thanks for your time,

Password Protect .exe's And .zip's

I want to build a program that runs on windows start-up and whenever certain .exe's and .zip's on my computer are clicked, before opening them, it asks for a password, and if it doesnt receive the right password, the .exe or .zip won't open. So basically a security program for programs on my computer, like lets say that I wanted to have it so Visual Basic 6 needed a password to open it...I want to build something like this, and I specify the .zip and .exe names that need passwording. Does anybody know how I could make this? Thanks.

Protect Method
Can you guys list the properties of the protect method.
Does the protect method properties vary with different versions of VB?

if i protect my worksheet with the protect method, does this mean i will not be abel to open that worksheet by double clicking it's reference in windows explorer?

if i try to do that, will i end up with an empty worksheet or something like that?

Password Protect A Tab... How ?
Password protrcting a Tab... howdo i do it ?

i have this code that doesn't work...

VB Code:
Private Sub Tab1_Click()Dim pwd as Stringpwd = "superpassword"Inputbox = "Enter password", "Enter password"If Inputbox = pwd then'show tabElse:'don't show tabEnd IfEnd Sub

Am i going about it right ? if not whats wrong ? and how can i fix my code ?

Password Protect
I know there are quite a few password breakers that people can download for free off the net, but is there a way to better protect the password to VB code so that this can be prevented?

Thanks for any help!

Protect A Cd From Coping
dear sir,
can we protect a cd coping from one media to another media
is it possible? how
tell me plz.

Protect My Software In A Lan?

how to i protect my software by limit the number of simultaneous conections to my .exe?

I like to a opensource component, i tryed activelock, but this cannot perform this protection...


Copyright © 2005-08, All rights reserved