I took most all of the code out so you wouldn't have to go through it. With that code removed it still happens. The first message will say "A file named ...xls aready exists in the in this locations. Do you want to replace it."
Thanks for you help!
Sub PickShift()
Dim c As Variant
Dim Dataloc As String
CellAddr = ActiveCell.Address
If ActiveCell.Offset(0, 8) = True Then
ws = Range("L1").Value
Dim UserID As String
YourName = InputBox("Enter Your Name: ", "Welcome ")
Dim WbSource As Workbook, WbDest As Workbook
Set WbSource = ThisWorkbook 'book where this code is located
On Error Resume Next 'enables continued processing if an error occurs
Dataloc = "P:\CUSTSERVICE\Custserv Online Sign Ups\rb\OSM RB BobThuli.xls"
' Display a message stating the file in use.
If IsFileOpen(Dataloc) Then
MsgBox ("File is currently in use by another user. Please try again later." _
& vbNewLine & "If this lasts over 15 minutes contact the I-team.")
Exit Sub
End If
Workbooks.Open Dataloc, , , , "HotIssue", "HotIssue"
'
MsgBox ("Just Tesing")
Application.ScreenUpdating = True 'Turn back on Screen updating
End If
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.ScreenUpdating = True 'Turn back on Screen updating
Success = MsgBox("You have successfully picked up this shift.", , "Success")
End Sub
' This function checks to see if a file is open or not. If the file is
' already open, it returns True. If the file is not open, it returns
' False. Otherwise, a run-time error occurs because there is
' some other problem accessing the file.
Function IsFileOpen(filename As String)
Dim filenum As Integer, errnum As Integer
On Error Resume Next ' Turn error checking off.
filenum = FreeFile() ' Get a free file number.
' Attempt to open the file and lock it.
Open filename For Input Lock Read As #filenum
Close filenum ' Close the file.
errnum = Err ' Save the error number that occurred.
On Error GoTo 0 ' Turn error checking back on.
' Check to see which error occurred.
Select Case errnum
' No error occurred.
' File is NOT already open by another user.
Case 0
IsFileOpen = False
' Error number for "Permission Denied."
' File is already opened by another user.
Case 70
IsFileOpen = True
' Another error occurred.
Case Else
Error errnum
End Select
End Function
Bookmarks