So I have five workbooks. Four are for Users, one is a Master. The Master opens the other four, one at a time, and copies a portion of the data from them, and pastes it into the Master. However, utilizing an application called Dropbox, if data is imported from a workbook a User has open at the time, it creates a "conflicted copy". What I need is to have my current code verify the file it is attempting to open is not currently being used. If it is being used, I need the macro to stop in its tracks and provide a message that reads, "Workbook (Filename that is currently open) is currently open".
Here is my code currently:
Sub ImportWorkbooks()
Dim wbData As Workbook, wsMaster As Worksheet
Dim NR As Long, fPATH As String, fNAME As String
fPATH = "C:\Users\Officer\Dropbox\Leads\"
Set wsMaster = ThisWorkbook.Sheets("Sheet1")
With wsMaster
NR = .Range("B" & .Rows.Count).End(xlUp).Row + 1
fNAME = Dir(fPATH & "Leads*.xls")
Do While Len(fNAME) > 0
Set wbData = Workbooks.Open(fPATH & fNAME)
Range("B12:S1000").Copy .Range("B" & NR)
wbData.Close False
NR = .Range("B" & .Rows.Count).End(xlUp).Row + 1
fNAME = Dir
Loop
Range("B12:S1000").Select
Selection.NumberFormat = "@"
Selection.HorizontalAlignment = xlLeft
End With
Any help would be appreciated!
Bookmarks