error help

Dannyc989

Registered User.
Local time
Today, 19:45
Joined
Dec 18, 2013
Messages
46
I have this code in a module but it comes up with a compile error invalid outside procedure error at the bold red line...can anyone help??

Dim fso As Scripting.FileSystemObject
Dim sSourceDir As String, sDestinationDir As String

Setfso = New Scripting.FileSystemObject

sSourceDir = Me.Quote_File_Directory_Ref
sDestinationDir = "C:\Users\Daniel\Desktop\NTProjects\" & [Project Number] & "_" & [Client] & "_" & [Description] 'No ending back slash for the final directory!

fso.CopyFile sSourceDir, sDestinationDir, True

MsgBox "Files copied"
 
Chznge Setfso to Set fso
 
Same error occurs
 
Code has to be in a subroutine, like a Sub or a Function or a Property.

Code:
Private Sub Test123()
   Dim fso As New Scripting.FileSystemObject
   Dim sSourceDir As String, sDestinationDir As String

   sSourceDir = Me.Quote_File_Directory_Ref
   sDestinationDir = "C:\Users\Daniel\Desktop\NTProjects\" & [Project Number] & "_" & [Client] & "_" & [Description] 'No ending back slash for the final directory!

   fso.CopyFile sSourceDir, sDestinationDir, True

   MsgBox "Files copied" 
End Sub
 

Users who are viewing this thread

Back
Top Bottom