PDA

View Full Version : staff / alternative



snb
04-15-2012, 01:29 PM
If a moderator isn't 'staff' in this forum who is ?
I can only send PM's to 'staff' but I have no idea how to find them.

I found xld's article in the kb on checking whether a file is open or not.

An alternative could be:


Function IsFileOpen(FileName As String)
On Error Resume Next

Open FileName For Input Lock Read As #1
Close

IsFileOpen = Err <> 0 And Dir(FileName) <> ""
End Function

Sub test()
If IsFileOpen("C:\MyTest\volker2.xls") Then Workbooks.Open "C:\MyTest\volker2.xls"
End Sub

But the next code is equivalent:

sub snb()
getobject "C:\Mytest\volker2.xls"
end sub

Aflatoon
04-16-2012, 02:28 AM
How is that the equivalent? Surely that just tells you if you already have the file open, not someone else?

snb
04-16-2012, 06:40 AM
Correct; wouldn't adding 'on error resume next' & if err.number<>0 result in the equivalent ?

Aflatoon
04-16-2012, 07:00 AM
I would expect it to just open a read-only copy, probably popping up a prompt.

Bob Phillips
04-16-2012, 07:07 AM
This is about a KB article, not a request for help. I intend moving it to Potential KB articles again, before the end of the day, unless you can suggest a more appropriate forum than that, but not this one.

snb
04-16-2012, 07:13 AM
Because I couldn't comment in the kb subforum, nor had the rights to PM you (less than 10 posts) I put it here.
Do with it what you seem fit according to this forum's customs.



This is about a KB article, not a request for help. I intend moving it to Potential KB articles again, before the end of the day, unless you can suggest a more appropriate forum than that, but not this one.