Finding out whether a file is open in other computer

prajul89

Active Member
Joined
Jul 9, 2011
Messages
404
Code:
again:
'see if file is read only
If test = True Then Application.Wait TimeValue("00:00:02"): GoTo again:

'open file and update values in it

Here I want test to be true if the said file is already opened by some other user, else it should be false. Is it possible??

Basically I want my macro to wait for sometime and open only file which is not read only.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Try:

Code:
    Dim FileName As String
    FileName = "C:\temp\somefile.xls"
    If (GetAttr(FileName) And vbReadOnly) = 1 Then
        MsgBox FileName & " is readonly."
    Else
        MsgBox FileName & " is not readonly."
    End If

Change the FileName to suit.
 
Upvote 0
Nope that didn't worked. My knowledge is very little, but I think that code just shows whether a file is saved as a read only file while saving.

When opened "somefile" and run your macro the msg still appears that the file is not read only.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

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