Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error - 70 with FSO causes program Crash

Status
Not open for further replies.

SQL2KDBA69

Programmer
Feb 4, 2004
227
0
0
US
i have a seach and copy sub but when it get an error 70 the program crash. here is the sub :

Code:
Private Sub GetFolders(Folder)
    On Error Resume Next
    
    Dim fso2
    Dim ObjFolder
    Dim colFiles
    Dim strName As String
    Dim strPath As String
    Dim strCopy As String
    
    Set fso2 = CreateObject("Scripting.FileSystemObject")
    
    For Each Subfolder In Folder.SubFolders
        If Subfolder.Path <> "C:\UserFiles" Then
                DoEvents
                Set ObjFolder = fso2.GetFolder(Subfolder.Path)
                Set colFiles = ObjFolder.Files
                For Each objfile In colFiles
                    strName = objfile.Name
                    strPath = objfile.Path
                    If Len(strName) > 3 Then
                         If Right(UCase(strName), 4) = ".DOC" Or Right(UCase(strName), 4) = ".DOCX" Or _
                            Right(UCase(strName), 4) = ".PDF" Or Right(UCase(strName), 4) = ".XLS" Then
                            DoEvents
                            strCopy = "C:\UserFiles"
                            Print #1, "Source: " & strPath & " - Destination: " & strCopy & "\" & strName
                            lb_status.Caption = "Coping - " & strPath
                            lb_status.Refresh
                            If Not fso2.FileExists(strCopy & "\" & strName) Then
                                DoEvents
                                objfile.Copy (strCopy & "\" & strName)
                                
                            End If
                        End If
                    End If
                Next
        End If
    GetFolders Subfolder
    Next    
    
End Sub

any help is appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top