ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Code Locked for Viewing (https://www.excelbanter.com/excel-programming/431091-vba-code-locked-viewing.html)

AlForester

VBA Code Locked for Viewing
 
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.
--
WEW

Patrick Molloy

VBA Code Locked for Viewing
 
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



"AlForester" wrote in message
...
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.
--
WEW



AlForester

VBA Code Locked for Viewing
 
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.
--
WEW


"Patrick Molloy" wrote:

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



"AlForester" wrote in message
...
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.
--
WEW



Patrick Molloy

VBA Code Locked for Viewing
 
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" wrote in message
...
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.
--
WEW


"Patrick Molloy" wrote:

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



"AlForester" wrote in message
...
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.
--
WEW



Per Jessen

VBA Code Locked for Viewing
 
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" skrev i meddelelsen
...
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.
--
WEW


"Patrick Molloy" wrote:

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



"AlForester" wrote in message
...
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.
--
WEW




John

VBA Code Locked for Viewing
 
Have a look at this article it may or may not be of some help to you.

Password prompt for VBA project appears after Excel quits
http://support.microsoft.com/kb/280454
--
jb


"AlForester" wrote:

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.
--
WEW


AlForester

VBA Code Locked for Viewing
 
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.
--
WEW


"Patrick Molloy" wrote:

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" wrote in message
...
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.
--
WEW


"Patrick Molloy" wrote:

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



"AlForester" wrote in message
...
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.
--
WEW



AlForester

VBA Code Locked for Viewing
 
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.

--
WEW


"AlForester" wrote:

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.
--
WEW



All times are GMT +1. The time now is 09:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com