Hi all,

I have a repository workbook that has other workbooks copying to it. The code for this is below. What i need help with : if the repository workbook is open then I need the sending file to display a message "File alread open try again later" and then exit the sub. At the moment if the repository wb is open theres an error.

Public Sub TransferData()
If MsgBox("This facility is only for transfering information into " _
+ "the BISTD Central Register repository database. " _
+ "Are you sure you want to continue?", vbQuestion + vbYesNo) = vbNo Then
Exit Sub
End If



Worksheets("Register").Select
ActiveSheet.Unprotect
Dim bk1 As Workbook
Dim bk2 As Workbook
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Dim idx As Long
Set bk1 = ActiveWorkbook
Set bk2 = Workbooks.Open("F:\BISTD PMO Share\BISTD R&I Register Updates\RiskRepository.xls")
Set sh1 = bk1.Worksheets("Register")

On Error Resume Next
Set sh2 = bk2.Worksheets("WPP")
On Error GoTo 0
If Not sh2 Is Nothing Then
idx = sh2.Index
Application.DisplayAlerts = False
sh2.Delete
Application.DisplayAlerts = True
If idx > 1 Then
sh1.Copy after:=bk2.Sheets(idx - 1)
Else
sh1.Copy before:=bk2.Sheets(2)
End If
Else
sh1.Copy after:=bk2.Worksheets(bk2.Worksheets.Count)
End If
ActiveSheet.Name = "WPP"
ActiveWorkbook.Save
ActiveWorkbook.Close
Call isstrandata

End Sub