Hello all,
I have some code that has a successful OnError code that provides a message indicating that the file is currently in use by another user (error code 75 would normally populate). What I am trying to do however, is put an if statement in the error code so that if the error isn't caused by error code 75 then an alternative user friendly message will appear. As an example, if the file is not located in the correct file path error code 53 file not found would appear.
Any assistance would be greatly appreciated.
Here is my code for reference:
I have some code that has a successful OnError code that provides a message indicating that the file is currently in use by another user (error code 75 would normally populate). What I am trying to do however, is put an if statement in the error code so that if the error isn't caused by error code 75 then an alternative user friendly message will appear. As an example, if the file is not located in the correct file path error code 53 file not found would appear.
Any assistance would be greatly appreciated.
Here is my code for reference:
VBA Code:
Sub MoveEm_Redxx() 'Moving static files Off P Drive
Dim Itemx As Variant
Dim L As Long
'On Error GoTo grr
'Initial Variable levels
Itemx = 0
L = 65
''''''''''''''''''
Application.Run "Pro.XPro01"
Itemx = Itemx + 1: L = L + 1
Name Sheets(1).Range("B66").Value As _
Sheets(1).Range("E66").Value
Application.Run "Pro.XPro02"
Itemx = Itemx + 1: L = L + 1
Name Sheets(1).Range("B67").Value As _
Sheets(1).Range("E67").Value
Application.Run "Pro.XPro03"
Itemx = Itemx + 1: L = L + 1
Name Sheets(1).Range("B68").Value As _
Sheets(1).Range("E68").Value
Application.Run "Pro.XPro04"
Itemx = Itemx + 1: L = L + 1
Name Sheets(1).Range("B69").Value As _
Sheets(1).Range("E69").Value
Exit Sub
grr:
Error.Information.Caption = "The workbook located here:" & vbNewLine & Sheets(1).Range("B" & L).Value & vbNewLine & " Is currently in use by another user. Please ask them to exit then press continue..."
Error.Show 'can you have the resume or resume next in the two different buttons of the userform??? essentially to try again or to skip to the next line of code.
Resume
End Sub