Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
FSO.MoveFile
Morning all.
I'm trying to modify an existing macro to move a file from its source to a secondary folder if it finds an error, for later resolution. I.e., I'm using an existing macro grouping to update a series of workbooks to make for a common format for all our files, then if it finds an error in any of the files, we want to move it from the source location to a "errorfolder" destination for later processing/fixing. The goal is to set aside the files that have errors so we can just focus on "healthy" files, so we're not constantly having to start/stop and then retrace our steps. We've been trying the FSO.Move And we keep getting either 438 or 450 errors. 1- What would we need to modify out of the code below to resolve this? We're using Excel 2007. 2- can we move an open file or do we need to close the file first, and then move it? (I know, stupid question, but this is our first use of this method) ----------------------------------------------------- Sub ASaveErrorToSubFolder() 'same routine as AsaveNewFormat but when any errors found will save to the '\ErrorSaveFiles subfolder With Application .DisplayAlerts = True 'these can be changed to either true or false, depending 'on if you want the alerts or not. .ScreenUpdating = True 'Prevents from having to watch updating of files. End With Folder = ActiveWorkbook.Path 'this sets the folder of the source file FName = ActiveWorkbook.Name 'this looks at the existing file's name 'remove extension FName = Left(FName, InStr(FName, ".") - 1) ' this appears to remove the existing 'file's extension SaveName = Folder & "\ErrorSaveFiles\" & FName & ".xlsx" ' this tells where to 'save it, but one directory deeper. ' if you wish to have it save to another directory, you must specify that directory. xx On Error Resume Next 'This bypasses an error to keep the routine moving. ActiveWorkbook.SaveAs Filename:=SaveName, FileFormat:=xlOpenXMLWorkbook With ActiveWorkbook 'this command grouping is to save workbook after processing 'is completed, .Save 'do a READ ONLY SaveAS, and close the workbook. .ChangeFileAccess Mode:=xlOpenXMLWorkbook 'xlReadOnly xx '.Close 'comment for now, other macro closes wkbk. End With End Sub -------------------------------------------------------------------------------------- Thank you. Best, SteveB. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Help!!! MoveFile Method | Excel Programming | |||
Movefile "Permission Denied" | Excel Programming | |||
MoveFile problems | Excel Programming | |||
How to maintain the original date and time for the MoveFile command | Excel Programming |