S
Slim Slender
The following code tests whether a file is open on my computer and if
it isn't, it opens the file, and if it is already open, it tells me
that.
sub OpenMyFile()
dim myPath as string
dim myFile as string
dim wkbk as Workbook
myPath = "R:\share\ . . . Folder\"
myFile = "SomeFileName.xlsm"
set wlbk = Nothing
On Error Resume Next
set wkbk = Workbooks(myFile)
On Error GoTo 0
If wkbk Is Nothing Then
Set wkbk = Workbooks.Open(Filename:=myPath & myFile)
Else
MsgBox ("It's already open")
End If
End Sub
The problem is that the file is on a network drive and others can open
it. If someone else has it open, this routine will go ahead and open
in on my computer as (Read Only). I would prefer that it not do that
but instead give me the prompt that I would get if were to use to
navigate to it and try to open it. In that case there would be a
prompt telling who had it open and giving choices to open as Read Only
or Notifiy or Cancel. Can code to that effect be added to this
procedure?
it isn't, it opens the file, and if it is already open, it tells me
that.
sub OpenMyFile()
dim myPath as string
dim myFile as string
dim wkbk as Workbook
myPath = "R:\share\ . . . Folder\"
myFile = "SomeFileName.xlsm"
set wlbk = Nothing
On Error Resume Next
set wkbk = Workbooks(myFile)
On Error GoTo 0
If wkbk Is Nothing Then
Set wkbk = Workbooks.Open(Filename:=myPath & myFile)
Else
MsgBox ("It's already open")
End If
End Sub
The problem is that the file is on a network drive and others can open
it. If someone else has it open, this routine will go ahead and open
in on my computer as (Read Only). I would prefer that it not do that
but instead give me the prompt that I would get if were to use to
navigate to it and try to open it. In that case there would be a
prompt telling who had it open and giving choices to open as Read Only
or Notifiy or Cancel. Can code to that effect be added to this
procedure?