Consulting

Results 1 to 6 of 6

Thread: staff / alternative

  1. #1
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645

    staff / alternative

    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:

    [vba]
    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[/vba]

    But the next code is equivalent:

    [vba]sub snb()
    getobject "C:\Mytest\volker2.xls"
    end sub[/vba]

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    How is that the equivalent? Surely that just tells you if you already have the file open, not someone else?
    Be as you wish to seem

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Correct; wouldn't adding 'on error resume next' & if err.number<>0 result in the equivalent ?

  4. #4
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    I would expect it to just open a read-only copy, probably popping up a prompt.
    Be as you wish to seem

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    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.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    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.


    Quote Originally Posted by xld
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •