VBAProject Password Prompt

GMBJames

New Member
Joined
Aug 21, 2002
Messages
22
Hello all,
I'm using excel 2000 on a Windows 2000 machine and I'm getting a random error.
I've created a spreadsheet with some VBA code and have put a password on it to lock it. I'm having no problem with the code but, from time to time, after I close the file by exiting excel, the dialog box prompting me for the VBAProject Password will pop up. If I hit cancel three times it'll go away. Also, if I type in the actual password, the box will go away. In any case, it's not a big deal but it is annoying.
Has anyone else found this to be a problem or has an idea of what is causing it?
Thanks,
Jamie
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Could you post up the code (in it's entirety) you are using, there may be something in there that's causing your problem.
 
Upvote 0
Here it is...I've tried to make it as readable as possible:

MICROSOFT EXCEL OBJECTS:
THIS WORKBOOK:

Private Sub Workbook_Open()
Call DisableCut
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call EnableCut
End Sub

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If PrtOK Then
Cancel = False
Else
MsgBox "Can't print from here! Use the PRINT TIMESHEET button", vbInformation, "Timesheet Restriction"
Cancel = True
End If
End Sub
////////////////////////////////////////////////////////////////////////

FORMS:
Private Sub UserForm_Initialize()
Dim TitleTxt As String
TitleTxt = "Operations Staff"
With Me.ComboBox1
.AddItem "Operations Staff"
.AddItem "Kitchen Staff"
' .Text = TitleTxt
End With
With Me.ComboBox2
.AddItem Worksheets("EInfo").Range("E4")
.AddItem Worksheets("EInfo").Range("E5")
.AddItem Worksheets("EInfo").Range("E6")
.AddItem Worksheets("EInfo").Range("E7")
.AddItem Worksheets("EInfo").Range("E8")
.Text = Worksheets("EInfo").Range("E6")
End With
With Me.ComboBox4
.AddItem "Full Time Employees"
.Text = "Full Time Employees"
End With
End Sub

Private Sub ComboBox1_Change()
With ComboBox3
.Clear
If ComboBox1.Text = "Operations Staff" Then
.AddItem ""
.AddItem "Anthony"
.AddItem "John"
End If
If ComboBox1.Text = "Kitchen Staff" Then
.AddItem ""
.AddItem "Debra"
.AddItem "Eric"
End If
.ListIndex = 0
End With
End Sub

Private Sub CommandButton1_Click()
Me.Hide
Worksheets("EInfo").Range("H4").Formula = Me.ComboBox1.Text
Worksheets("EInfo").Range("D4").Formula = Me.ComboBox2.Text
Worksheets("EInfo").Range("K4").Formula = Me.ComboBox3.Text
Worksheets("EInfo").Range("I4").Formula = Me.ComboBox4.Text
Worksheets("EInfo").Range("A5").Formula = Me.TextBox1.Text
Worksheets("EInfo").Range("A6").Formula = Me.TextBox2.Text
Worksheets("EInfo").Range("A7").Formula = Me.TextBox3.Text
Worksheets("EInfo").Range("B4").Formula = Me.TextBox4.Text
Unload Me
Range("D12").Select
End Sub

Private Sub CommandButton2_Click()
Me.Hide
Unload Me
Range("D12").Select
End Sub

////////////////////////////////////////////////////////////////////////

MODULES:
Sub GetEmployeeInfo()
frmEmployeeInfo.Show
End Sub

Sub Quit()
Application.DisplayAlerts = False
Application.Quit
End Sub

Sub ClearTimesheetTimes()
Application.ScreenUpdating = False
ActiveSheet.Unprotect Password:="ABCDEFG"
Range("D12:E25,D28:E41,I12:L25,I28:L41,N12:V25,N28:V41,Z12:AE25,Z28:AE41").ClearContents
Sheets("EInfo").Range("A5:A7,B4,D4,H4,I4,K4").ClearContents
ActiveSheet.CheckBoxes.Value = xlOff
Range("D12").Select
ActiveSheet.Protect Password:="ABCDEFG"
End Sub

Sub PrintTimeSheet()
ActiveSheet.Unprotect Password:="ABCDEFG"
Application.ScreenUpdating = False
Range("D14:AE15,D18:AE19,D22:AE23,D30:AE31,D34:AE35,D38:AE39").Interior.ColorIndex = 15
Range("D12:AE13,D16:AE17,D20:AE21,D24:AE25,D28:AE29,D32:AE33,D36:AE37,D40:AE41").Interior.ColorIndex = x1None
Columns("F").Hidden = True
Call PrintNow
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Call DontPrintNow
Columns("F").Hidden = False
Range("D12:E25,D28:E41,I12:L25,I28:L41,N12:V25,N28:V41,Z12:AE25,Z28:AE41").Interior.ColorIndex = 19
ActiveSheet.Protect Password:="ABCDEFG"
Range("D12").Select
End Sub

Public PrtOK As Boolean

Sub PrintNow()
PrtOK = True
End Sub

Sub DontPrintNow()
PrtOK = False
End Sub

Sub DisableCut()
On Error Resume Next
Application.CommandBars("Standard").Controls.Item("Cut").Enabled = False
Application.CommandBars("Edit").Controls.Item("Cut").Enabled = False
Application.CommandBars("Cell").Controls("Cut").Enabled = False
Application.OnKey "^x", "NoNo"
End Sub

Sub EnableCut()
Application.CommandBars("Standard").Controls.Item("Cut").Enabled = True
Application.CommandBars("Edit").Controls.Item("Cut").Enabled = True
Application.CommandBars("Cell").Controls("Cut").Enabled = True
Application.OnKey "^x"
End Sub

Sub NoNo()
MsgBox ("ctrl + x has been disabled.") & Chr(13) & ("You cannot use the keyboard CUT command."), vbInformation, "Timesheet Restriction"
End Sub
/////////////////////////////////////////////////////////////////////////////////////

I know this is alot to go through...any help will be greatly appreciated.
Jamie
 
Upvote 0
Sorry, I'm at a loss really. There doesn't seem to be anything in your code, and more especially the BeforeClose part of it, that would cause what you're experiencing. Anyone else have an idea?
 
Upvote 0
Hi,

Just a shot in the dark...

Do you have any other code that is running at the same time as that shown above, eg contained within Personal.xls or in an add-in?
 
Upvote 0
Hi,

Both Richie and Andrew (thanks for this KB-articel :) have giving You some logical possibilities to trace the error-source.

Another approach is to
- Load You workbook
- Alter to the VB-editor
- Choose the command Tools | Reference
- Uncheck all reference - close the workbook
and reopening it. (Write down the reference if necessary).
- Add one reference stepwise and locate the error.

Hopefully the error will disappear by itself via these actions, ottherwise it will give You the source of error.

Perhaps it's time to rebuild the workbook. Heavily used XL-files tends to be corrupt...

Good Luck!
Dennis
 
Upvote 0
Richie,
as far as I am aware, there is no other code or add-in running.
Dennis,
I tried what you suggested. The first six references were checked and I was unable to clear three of them...those three being, "Visual Basic for Applications", "Microsoft Excel 9.0 Object Library", and "Microsoft Forms 2.0 Object Library". I get an error saying, "Can't remove control or reference; in use" when I try and uncheck them. I don't know what this means being that I can't clear these references. Maybe that's the problem?
Thanks,
Jamie
 
Upvote 0

Forum statistics

Threads
1,206,814
Messages
6,075,021
Members
446,114
Latest member
FadDak

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top