Function IsAlreadyOpen(testFileName As String) _ As Boolean
' The IsAlreadyOpen function determines whether ' a file that the user has requested is already ' open. (If it is, the program avoids the attempt ' to open it a second time.) Dim i
' Start out assuming the file is not open. IsAlreadyOpen = False ' Loop through the open forms, not including ' the MDI parent form. Use Visual Basic's ' Forms collection to identify each form in ' turn. (The Count property tells how many ' forms are currently open.) For i = 1 To Forms.Count - 1 With Forms(i) ' If the user has entered a file name ' that matches one of the open files, ' the function returns a value of True. If Trim(.formsFileName) = Trim(testFileName) _ Then IsAlreadyOpen = True End With Next i
End Function ' IsAlreadyOpen |
|