nuffcedd Posted June 8, 2007 Report Share Posted June 8, 2007 First thanks for all the great information I've recieved from these forums. My situation is this, I have multilpe filesthat need to be manipulated every day. Some need to be renamed and moved to folder "A" while another may need to be moved to Folder "B" with no name change then yet another file may need to be to be copied to folder"A" and "B". I've built one macro that looks for the first file, does what it needs to do with it, then looks for the next file and so on. My problem is there may be times that a file may not be there and this is causeing the macro to error out and quit. Is there some way to run a macro that can perform in "steps". Recognize if a "step" is performable, if so complete it and continue, if not, skip it and still continue. I thought the If file Exits or If file does not exist were my answer but I have not been able to get the macro to continue either way. Quote Link to comment Share on other sites More sharing options...
wbeldman Posted June 8, 2007 Report Share Posted June 8, 2007 Do you mean something like this? If File Exists: "aaa11111.pdf" Rename File or Files:"aaa11111.pdf" Move File or Files "bbb11111.pdf" End If If File Exists: "QQtoday" Rename File or Files:"QQtoday" Move File or Files "QQ20070608" End If If File Exists: "x.csv" Rename File or Files:"x.csv" Move File or Files "Gross Sales.xls" End If In Macro Explorer: category Files/Folders (and category Logic for If and End If) Quote Link to comment Share on other sites More sharing options...
nuffcedd Posted June 8, 2007 Author Report Share Posted June 8, 2007 Yes!, and say using your example, file "aaa111111.pdf" does not exist but I need the macro to continue with "QQtoday" opposed to ending. Quote Link to comment Share on other sites More sharing options...
nuffcedd Posted June 8, 2007 Author Report Share Posted June 8, 2007 Here is a snipit of my macro - No laughing, I know it doesn't work Clear All Variables: All If File Exists "ACH Unathorized CCDs.csv" Variable Set From File Date/Time Delay 250 Milliseconds Copy File or Files: "Unathorized CCDs.pdf" Delay 1 Seconds Copy File or Files: "Unathorized CCDs.pdf" Delay 1 Seconds Delete File or Files: "Unathorized CCDs.pdf" Else Clear All Variables: All If File Exists "Five Star Credits.pdf" Variable Set From File Date/Time Delay 250 Milliseconds Copy File or Files: "Five Star Credits.pdf" Delay 1 Seconds Copy File or Files: "Five Star Credits.pdf" Delay 1 Seconds Delete File or Files: "Five Star Credits.pdf" Else End If End If Quote Link to comment Share on other sites More sharing options...
wbeldman Posted June 9, 2007 Report Share Posted June 9, 2007 I asume you want to do the following: If "ACH Unathorized CCDs.csv" exists then do 3 copy actions. If "Five Star Credits.pdf" exists then do 3 copy actions. These two lines are not related to each other, but you placed an Else in between. Your code states: If "ACH Unathorized CCDs.csv" exists then do 3 copy actions Else (if "ACH Unathorized CCDs.csv" doesn't exist) and If "Five Star Credits.pdf" exists then 3 copy actions. Make separate code blocks for each file starting with If File Exists. Note that every Else is optional (see the bottem of your example). Quote Link to comment Share on other sites More sharing options...
nuffcedd Posted June 11, 2007 Author Report Share Posted June 11, 2007 That did it. Thanks a bunch!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.