Thanks Xlnitwit
If I go one step back and want to know just the status of the file in the shared folder. I mean if that file is opened or not. For that purpose I just found a code on the web
Dim MyAccess As Object
Sub TestFileOpened()
If IsFileOpen("path to shared folder of Dropbox") Then
Set MyAccess = GetObject(, "Access.Application")
MsgBox ("Already in use.")
MyAccess.Quit
Else
Set MyAccess = CreateObject("Access.Application")
MsgBox "File not in use!"
MyAccess.Visible = True
MyAccess.OpenCurrentDatabase ("path to shared folder of Dropbox")
End If
End Sub
Function IsFileOpen(filename As String)
Dim filenum As Integer, errnum As Integer
On Error Resume Next ' Turn error checking off.
filenum = FreeFile() ' Get a free file number.
' Attempt to open the file and lock it.
Open filename For Input Lock Read As #filenum
Close filenum ' Close the file.
errnum = Err ' Save the error number that occurred.
On Error GoTo 0 ' Turn error checking back on.
' Check to see which error occurred.
Select Case errnum
' No error occurred.
' File is NOT already open by another user.
Case 0
IsFileOpen = False
' Error number for "Permission Denied."
' File is already opened by another user.
Case 70
IsFileOpen = True
' Another error occurred.
Case Else
Error errnum
End Select
End Function
This works fine for my PC. But if I use this from another PC it says file not found.Would you please review it when you have some time as it would be a complicated one.
Bookmarks