I have a form that on open checks whether an Excel file on the server is open or not, be fore certain other functions occur. If the file is open I get a message, if the file is not open then the queries run. What I would like is to know who has the Excel file open. Can this be written into the code below,
Any help very welcome, as this is now well beyond my understanding of VBA.
Many thanks
Code:
Private Sub Form_Open(Cancel As Integer)
DoCmd.Maximize
DoCmd.ShowToolbar "Ribbon", acToolbarNo
Dim location As String
Dim wbk As Workbook
location = "F:\Victoria Line\Bombardier\Maintenance\PLANNING DANNY AND LAWRENCE\KM run\Km Forecast\Burst Report & Predict - MASTER.xlsx"
Set wbk = Workbooks.Open(location)
'Check to see if file is already open
If wbk.ReadOnly Then
ActiveWorkbook.Close
MsgBox “Burst Report file is open and mileage cannot be updated"
GoTo CONTINUE:
End If
ActiveWorkbook.Close
DoCmd.SetWarnings False
On Error Resume Next
DoCmd.OpenQuery "kmnow_delete_qry"
On Error Resume Next
DoCmd.OpenQuery "kmnow_insert_qry"
On Error Resume Next
DoCmd.SetWarnings True
CONTINUE:
DoCmd.OpenForm FormName:="cal equip 2 form"
DoCmd.OpenForm FormName:="training_overdue"
End Sub
Any help very welcome, as this is now well beyond my understanding of VBA.
Many thanks