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