Thread: Move File
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Miguel Zapico
 
Posts: n/a
Default Move File

I have tried the code, and I cannot get the same error. This is the code I
used:
Sub test()
Application.EnableEvents = False
Application.ScreenUpdating = False
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
PathOld = "c:\old\" 'Change as needed
Path = "c:\new" ''Change as needed
Filename = Dir(Path & "\*.xls", vbNormal)
Do Until Filename = ""
Set Wkb2 = Workbooks.Open(Filename:=Path & "\" & Filename)
For Each WS In Wkb2.Worksheets
WS.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Cou nt)
Next WS
Wkb2.Close False
fso.MoveFile Path & "\" & Filename, PathOld
Filename = Dir()
Loop
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

Miguel.