Check to see if a file is in use.

StevenD

Active Member
Joined
Nov 17, 2004
Messages
262
Hi I want to check if a files are in use over the network.

When I open the workbook it says that the file is in use, and i can open as read only but this is time consuming.

Is there any code to check if the file is in use?

Thanks

Steve

I have tried the following code but I think it only works for the PC i am currently using.
Code:
Private Function WorkbookIsOpen(wbname) As Boolean
' Returns TRUE if the workbook is open
Dim wb As Workbook
On Error Resume Next
Set wb = Workbooks(wbname)

If Err = 0 Then
WorkbookIsOpen = True
Else
WorkbookIsOpen = False
End If
End Function


Sub TestWBOpen()
Dim wbname As String

wbname= "='x:\camera diagnostics\cameracomport.xls"
If wbname.open = true Then
MsgBox "Workbook " & wbname & " is open"
Else
MsgBox "The workbook is NOT open"
End If
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,202,990
Messages
6,052,958
Members
444,621
Latest member
MIKOLAJ_R

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top