LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help!!! MoveFile Method CAM Excel Programming 3 October 11th 06 03:13 AM
Movefile "Permission Denied" Gordon Gecko[_2_] Excel Programming 0 June 9th 05 08:44 PM
MoveFile problems [email protected] Excel Programming 1 December 28th 04 03:24 PM
How to maintain the original date and time for the MoveFile command Wellie Excel Programming 0 March 3rd 04 03:33 AM


All times are GMT +1. The time now is 03:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"