Consulting

Results 1 to 3 of 3

Thread: if worksheet already open then dont open again

  1. #1

    if worksheet already open then dont open again

    I have made two worksheet linked with each other...when i click button "open my sheet" other worksheet automatically open in invisible mode and again if i click button "open my sheet' then a msg appears "you have already open the spec file do u want to reopen again.yes or no"..i want that if my "spec file already open " then dont open again...and the msg does not appear again..

    also find the picture of the said msg which i have attached.

    please help me out of this problem as soon as possible

    thanks in advance..
    Attached Files Attached Files

  2. #2
    someone please help me out of this problem

  3. #3
    VBAX Mentor
    Joined
    Aug 2008
    Posts
    323
    Location
    [VBA]Function FileLocked(strFileName As String) As Boolean
    On Error Resume Next
    'Dim objAccess As Object
    ' Set objAccess = CreateObject("Access.Application")
    ' If the file is already opened by another process,
    ' and the specified type of access is not allowed,
    ' the Open operation fails and an error occurs.
    Open strFileName For Binary Access Read Write Lock Read Write As #1
    Close #1
    ' If an error occurs, the document is currently open.
    If Err.Number <> 0 Then
    ' Display the error number and description.
    ' MsgBox "Error #" & Str(Err.Number) & " - " & Err.Description
    FileLocked = True
    Err.Clear

    End If
    End Function
    [/VBA]

    Where StrFileName is the path to the file. You can modify the code to check is the file is locked it means the file is open.
    I am a Newbie, soon to be a Guru

Posting Permissions

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