I am having a problem with the VBA code below it works fine with
Fileout.Write "This is a test"
but files when
Fileout.Write Cl.Value, Fldr & ""
Also it seems to be overwriting the same line so I think a new line command somewhere. Also os it posible to get the code to append to the list rather than overwrite.
Your help will be greatly appreciated
Regards
Des
Fileout.Write "This is a test"
but files when
Fileout.Write Cl.Value, Fldr & ""
Also it seems to be overwriting the same line so I think a new line command somewhere. Also os it posible to get the code to append to the list rather than overwrite.
Your help will be greatly appreciated
Code:
Sub Copy_Move_Files()
Dim fso As Object
Dim Cl As Range
Dim Fldr As String
Set fso = CreateObject("scripting.filesystemobject")
With Application.FileDialog(4)
.AllowMultiSelect = False
If .Show = -1 Then Fldr = .SelectedItems(1)
End With
For Each Cl In Range("A1", Range("A" & Rows.Count).End(xlUp))
If fso.FileExists(Cl.Value) Then
fso.CopyFile Cl.Value, Fldr & "\"
Call Write_file
End If
Next Cl
End Sub
Sub Write_file()
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim Fileout As Object
Set Fileout = fso.CreateTextFile("C:\Users\desmo\Desktop\Audit Trail.txt", True, True)
Fileout.Write Cl.Value, Fldr & "\"
Fileout.Close
End Sub
Regards
Des