VBA Code Locked for Viewing

A

AlForester

I have a spreadsheet that does not have a password for the file, but the code
is locked for viewing with a password.

Does anybody know what would cause the password prompt to be displayed when
the file is closed? This will happen either when the user clicks the X or
when a button code runs to close the file and leave excel open or close excel
with application.quit. If the code leaves excel open, the password prompt
appears when the user finally closes excel.

Any thoughts would be greatly appreciated.
 
P

Patrick Molloy

the VBA has a separate password. Open the IDE (ALT+F11) then look under
Tools / VBA Project Properties
In the form, switch to the Protection tab - you'll see there that it may be
password protected
 
A

AlForester

Patrick,
I protected the code from prying eyes. My problem is when the user closes
the file, the password prompt is displayed. The user is not trying to access
the code, they are just closing the spreadsheet. Once the spreadsheet is
closed, the password prompt is displayed, the user does not know the password
and cannot dismiss the prompt. The user has to go to task manager and cancel
the process. In my code the user is never asked for a password or the
anything related to the password.
 
P

Patrick Molloy

how strange. The VBA is protected separately so that the user can alter the
sheets and save changes. I've never heard of the password being asked for
like this. Does your code amend any code modules?


AlForester said:
Patrick,
I protected the code from prying eyes. My problem is when the user closes
the file, the password prompt is displayed. The user is not trying to
access
the code, they are just closing the spreadsheet. Once the spreadsheet is
closed, the password prompt is displayed, the user does not know the
password
and cannot dismiss the prompt. The user has to go to task manager and
cancel
the process. In my code the user is never asked for a password or the
anything related to the password.
 
P

Per Jessen

Hi

Just a guess.

Do you have a workbook_BeforeClose event in the workbook. If so there maybe
is an error in the code, which is stopping the code trying to show the code
module....

Hopes this helps.
....
Per

AlForester said:
Patrick,
I protected the code from prying eyes. My problem is when the user closes
the file, the password prompt is displayed. The user is not trying to
access
the code, they are just closing the spreadsheet. Once the spreadsheet is
closed, the password prompt is displayed, the user does not know the
password
and cannot dismiss the prompt. The user has to go to task manager and
cancel
the process. In my code the user is never asked for a password or the
anything related to the password.
 
A

AlForester

Patrick,

The only code that I can think of or can find are a couple of calls and
changes to the sheets scrollarea property. They work as expected and
everything is fine. I tested this with a stripped down file and was not
asked for a password.

Per,

You suggested an error in BeforeClose event. I do have a BeforeClose event
with the following code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If (SaveWorkbook) Then

Call CleanupForClose
If (Not ThisWorkbook.Saved) Then ThisWorkbook.Save

End If

End Sub

Public Sub CleanupForClose()
Dim objWorksheet As Worksheet

For Each objWorksheet In Worksheets

objWorksheet.Activate
Call SplitScreen(objWorksheet)
Range("A1").Activate

Next objWorksheet
Sheet1.Activate
Application.Calculation = xlCalculationAutomatic

End Sub

Public Sub SplitScreen(objWorksheet As Worksheet, Optional lngRow As Long =
0, Optional lngCol As Long = 0)
On Error Resume Next

With objWorksheet

.Parent.Activate
.Activate
With ActiveWindow

.SplitColumn = lngCol
.SplitRow = lngRow

End With

End With

On Error GoTo 0

End Sub

This code compiles ok. SplitScreen is called from other code and works as
designed without errors.

When I did run across an error in the code, the dialog box would appear
indicating an error, but Debug code would be unavailable. The only option
was to end the code. The password prompt would not appear.

John,

I will dig into the parent child reference to see if this fits this situation.

Thanks all.
 
A

AlForester

With excel 2003 and the following conditions:
(1) Create a UserForm
(2) Place a CommandButton on a sheet to open the form
(3) Create code to open the form
(4) Protect the VBA code from viewing with a password
(5) Close the spreadsheet and open it again so the code is locked

If you open the form and do not change anything on the spreadsheet, when the
spreadsheet is closed, there is not prompt for the password.

If you open the form and change a cell's value, either before or after the
form, when the spreadsheet is closed, there will be a prompt for the password.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top