Here are all the macros that I believe could be causing the error.
Thisworkbook code:
<code>
Code:
Private Declare Function FindWindowEx& Lib "User32" Alias "FindWindowExA" _
(ByVal hWnd1&, ByVal hWnd2&, ByVal lpsz1$, ByVal lpsz2$)
Private Declare Function ShowWindow& Lib "User32" (ByVal hWnd&, ByVal nCmdShow&)
Private Sub Workbook_Open()
Application.ScreenUpdating = False
On Error Resume Next
For Each s In Worksheets
s.Visible = False
If s.Name = "Intro Page" Then s.Visible = True
Next s
Sheets("Intro Page").Activate
Sheets("Intro Page").Range("W42").Value = "no"
Range("C6").Select
'disable access to VBA editor
Application.OnKey "%{F11}", "Access_VBA_Editor"
Application.OnKey "%{F8}", "Access_Macro_List"
Application.ScreenUpdating = True
Call TaskBar_Hide
Call GetStarted
If Range("T28").Value = "BLANK" Then
Range("R15").ClearContents
Range("R17").ClearContents
Range("AR15").ClearContents
UserForm1.Show
Else
Range("R15").ClearContents
Range("R17").ClearContents
Range("AR15").ClearContents
UserForm5.Show
End If
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Sheets("Intro Page").Range("W42").Value = "no" Then
Cancel = True
ElseIf Sheets("Intro Page").Range("W42").Value = "yes" Then
Application.OnKey "%{F11}", ""
Application.OnKey "%{F8}", ""
Cancel = False
End If
End Sub
<code>==================================================================
Close workbook command macro
<code>
Code:
Sub EXIT_Workbook()
Sheets("Intro Page").Range("W42").Value = "yes"
'Application.ScreenUpdating = False
i = MsgBox("This will save and close the QC Processing Workbook!" & vbCrLf & "Are you ready to leave?", vbYesNo + vbExclamation + vbDefaultButton2)
If i = 7 Then 'NO
Sheets("Intro Page").Range("W42").Value = "no"
If Sheets("Intro Page").Range("R15").Value = "" Or Sheets("Intro Page").Range("R17").Value = "" Then
UserForm5.Show
Else
Exit Sub
End If
ElseIf i = 6 Then 'YES
' clear username field and password field
Range("R15").ClearContents
Range("R17").ClearContents
' log the time out
Sheets("USER HISTORY").Activate
ActiveSheet.Unprotect Password:="bioe1025"
Range("B1").End(xlDown).Offset(0, 3).Value = Time
ActiveSheet.Protect Password:="bioe1025"
ActiveWorkbook.Save
Call TaskBar_Show
Call FinishClose
ActiveWorkbook.Close
End If
'Application.ScreenUpdating = True
End Sub
==========================================================================================<code>
Userform1
<code>
Code:
Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please select the CANCEL button on the form!"
End If
End Sub
Private Sub CommandButton1_Click()
UserForm1.Hide
If Range("R15").Value = "" Then
MsgBox "No user selected, please try again.", vbCritical, "ATTENTION!"
UserForm1.Show
End If
' ** SAVE THE FILE **
Dim sPath As String
'Specify directory
sPath = "\\Ferrari\common\Product QC\BioPrep QC\PrepaCyte-CB\PrepaCyte-CB QC\510k Lot Testing\" & Range("T21").Value
'Test if directory exists
If Dir(sPath, vbDirectory) = "" Then
MkDir sPath
ChDir "\\Ferrari\common\Product QC\BioPrep QC\PrepaCyte-CB\PrepaCyte-CB QC\510k Lot Testing\" & Range("T21").Value
'Format(Month(today), "MM") & Format(Day(today), "DD") & Format(Year(today), "YYYY")
ActiveWorkbook.SaveAs Filename:=(Range("T20").Value & " LOT# " & Range("T21").Value & " RM# " & Range("T23").Value & ".xls")
MsgBox ("File was saved with the following name: " & Range("T20").Value & "LOT#" & Range("T21").Value & " RM#" & Range("T23").Value & ".xls")
Else
'Test if file exists
Dim sFile As String
' Name file
sFile = "\\Ferrari\common\Product QC\BioPrep QC\PrepaCyte-CB\PrepaCyte-CB QC\510k Lot Testing\" & Range("T20").Value & "LOT#" & Range("T21").Value & " RM#" & Range("T23").Value & ".xls"
If Dir(sFile) <> "" Then
Activeworbook.Save
End If
End If
Range("B4").Select
End Sub
Private Sub CommandButton2_Click()
UserForm1.Hide
Call EXIT_Workbook
End Sub
Private Sub CommandButton3_Click()
Sheets("Intro Page").Range("AR15").ClearContents
Sheets("Intro Page").Range("R17").ClearContents
UserForm1.Hide
UserForm2.Show
End Sub
<code>===================================================================================
Userform2
<code></code></code></code></code></code></code></code><code><code><code><code><code>
Code:
</code></code></code></code></code>
<code><code><code><code><code><code><code> Option Explicit
Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please select the CANCEL button on the form!"
End If
End Sub
Private Sub CommandButton1_Click()
UserForm2.Hide
If Range("Q5").Value = True Then
UserForm3.Show
Else
MsgBox "Number entered is not correct, please try again.", vbCritical, "ATTENTION!"
UserForm2.Show
End If
End Sub
Private Sub CommandButton2_Click()
UserForm2.Hide
Sheets("Intro Page").Range("R17").ClearContents
UserForm5.Show
End Sub
</code></code></code></code></code></code></code><code><code><code><code><code>
</code></code></code></code></code>
<code><code><code><code><code><code><code> <code>
=====================================================================================================
Userform3
<code>
</code></code></code></code></code></code></code></code></code><code><code><code><code><code>
Code:
</code></code></code></code></code>
<code><code><code><code><code><code><code><code><code> Option Explicit
Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please select the CANCEL button on the form!"
End If
End Sub
Private Sub CommandButton1_Click()
If Sheets("Intro Page").Range("R17").Value = Sheets("Intro Page").Range("R18").Value Then
'Loop to find row
UserForm5.Hide
Sheets("PASSWORD ENTRY").Range("D2").Select
Do
If ActiveCell.Value <> Range("J15").Value Then
Selection.Offset(1, 0).Select
End If
Loop Until ActiveCell.Value = Range("J15").Value
ActiveCell.Offset(0, 3).Select
ActiveCell.ClearContents
ActiveCell.Value = ActiveCell.Offset(0, -2).Value & Sheets("Intro Page").Range("R17").Value
MsgBox "Password has been changed to your initials plus the 5 digit number you entered.", vbExclamation, "ATTENTION!"
End If
UserForm5.Show
End Sub
Private Sub CommandButton2_Click()
UserForm3.Hide
UserForm5.Show
End Sub
</code></code></code></code></code></code></code></code></code><code><code><code><code><code>
</code></code></code></code></code><code><code><code><code><code><code><code><code><code> <code>================================================================================================
Userform5
<code>
</code></code></code></code></code></code></code></code></code></code></code><code><code><code><code><code>
Code:
</code></code></code></code></code>
<code><code><code><code><code><code><code><code><code><code><code> Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please select a user and enter the correct password." & vbCrLf & "Click the ""EXIT"" button to leave the workbook."
End If
End Sub
Private Sub CommandButton1_Click()
UserForm5.Hide
If Range("R15").Value = "" Then
MsgBox "No user selected, please try again.", vbCritical, "ATTENTION!"
UserForm5.Show
End If
If Sheets("PASSWORD ENTRY").Range("M15").Value = False Then
MsgBox "Password entered in incorrect, please try again.", vbCritical, "ATTENTION!"
Sheets("Intro Page").Range("R17").ClearContents
UserForm5.Show
End If
Sheets("USER HISTORY").Activate
ActiveSheet.Unprotect Password:="bioe1025"
If Range("B2").Value = "" Then
Range("B2").Value = Sheets("Intro Page").Range("R15").Value
ActiveCell.Offset(0, 1).Select
Selection.Value = Date
Selection.Offset(0, 1).Select
Selection.Value = Time
Else
Range("B1").End(xlDown).Offset(1, 0).Select
Selection.Value = Sheets("Intro Page").Range("R15").Value
ActiveCell.Offset(0, 1).Select
Selection.Value = Date
Selection.Offset(0, 1).Select
Selection.Value = Time
End If
ActiveSheet.Protect Password:="bioe1025"
End Sub
Private Sub CommandButton2_Click()
UserForm5.Hide
UserForm2.Show
End Sub
Private Sub CommandButton3_Click()
UserForm5.Hide
Call EXIT_Workbook
End Sub
</code></code></code></code></code></code></code></code></code></code></code><code><code><code><code><code>
</code></code></code></code></code>
<code><code><code><code><code><code><code><code><code><code><code>
<code></code></code></code></code></code></code></code></code></code></code></code></code>