Results 1 to 2 of 2
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Thanked 0 Times in 0 Posts

    the file is free? (2000 sr 1)

    i need a code to loop a file and if the file is free for read and write goto Msgbox...
    I dont remenber if this coide make tath? in other case need code:-)

    Sub TRAPFILE()
    Do Until RunUpdateChk = True
    'Inserire qui la macro successiva al controllo della stampa terminata...
    MsgBox "Call IMPORT_L0848.epf"

    End Sub
    Function RunUpdateChk() As Boolean
    If IsFileUpdated("C:EPFL0848.EPF") Then
    If IsFileLock("C:EPFL0848.EPF", "C:EPFBK") Then
    RunUpdateChk = True
    End If
    End If
    End Function
    Function IsFileUpdated(strFilePath$) As Boolean
    'You must select Tools | References... (in the Visual Basic Editor), locate Microsoft Scripting Runtime in the list, tick its check box and click OK.
    Dim fs As New FileSystemObject, fil As file
    Set fil = fs.GetFile(strFilePath)
    If DateValue(fil.DateCreated) = Date Then IsFileUpdated = True
    End Function
    Function IsFileLock(strFilePath$, strTmpPath$) As Boolean
    Dim fs As New FileSystemObject
    Dim fil As file, strTmp$
    Set fil = fs.GetFile(strFilePath)
    strTmp = fil.Path
    On Error Resume Next
    fil.Move strTmpPath
    If Err <> 0 Then IsFileLock = True
    fil.Move strTmp
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: the file is free? (2000 sr 1)

    The RunUpdateChk function will return True if the file has been updated and is not locked. It will return False if the file has not been updated, or if it is locked (or both).

    So the loop in TRAPFILE will run continuously as long as the file has not been updated. If that is what you want, the code is fine.

Posting Permissions

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