Bienvenido a la mayor comunidad de usuarios EXCEL

Regístrate gratis ahora para ver contenidos y descargas sin restricciones!

Regístrate gratis

Validar un libro si esta abierto por otro usuario

Akapella

Member
Registrado
23 Abr 2021
Mensajes
46
si alguien podria echarle un vistazo a ver he googleado y nada que consigo alguna información al respecto


Sin permisos de acceso
 
Solución
Cambio tu codigo de validacion por este otro:

Código:
Sub ChkFileStatus()

    ' Test to see if the file is open.
    If IsFileOpen("C:\Users\purin\Downloads\Book1 - Copy.xlsx") Then
        ' Display a message stating the file in use.
        MsgBox "Archivo Abierto!"
    Else
        ' Display a message stating the file is not in use.
        MsgBox "Archivo cerrado!"
    End If

End Sub

' This function checks to see if a file is open or not.
Function IsFileOpen(filename As String)
    Dim filenum As Integer, errnum As Integer

    On Error Resume Next
    filenum = FreeFile()
   
    ' Attempt to open the file and lock it.
    Open filename For Input Lock Read As #filenum
    Close filenum          ' Close the file.
    errnum = Err...
Cambio tu codigo de validacion por este otro:

Código:
Sub ChkFileStatus()

    ' Test to see if the file is open.
    If IsFileOpen("C:\Users\purin\Downloads\Book1 - Copy.xlsx") Then
        '...
Para poder visualizar el resto de este tema y sus adjuntos:
. Si nunca te has registrado puedes registrarte gratis aquí
. Si ya te has registrado debes
iniciar sesión aquí
 
Última edición:
Volver
Arriba