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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CopyFolder error from CD

Status
Not open for further replies.

Fr33dan

Programmer
Jun 28, 2007
79
US
I'm trying to write code that will copy all the files and folders from a CD to a folder on my hard drive with the same name as the CD volume label. Then it will alert me to insert the next disk and copy those files. I get an "Invalid procedure call or argument" error on fso.CopyFolder line:
Code:
Option Explicit
Private Declare Function MessageBox _
        Lib "User32" Alias "MessageBoxA" _
           (ByVal hWnd As Long, _
            ByVal lpText As String, _
            ByVal lpCaption As String, _
            ByVal wType As Long) _
        As Long
Sub copyCD()
    Dim fol
    Dim fso As Object
    Dim drive As Object
    Set fso = CreateObject("scripting.filesystemobject")
    While (MessageBox(&H0, "Please insert cd into Drive", "Insert CD", vbOKCancel) = vbOK)
        Set drive = fso.GetDrive("E")
        fol = "C:\CDs\" & drive.VolumeName & "\"
        
        If fso.FolderExists(fol) = False Then
            fso.CreateFolder (fol)
        End If
        fso.CopyFolder Source:=drive.Path, Destination:=fol
    Wend
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top