Jump to content
Macro Express Forums

If File Exists Question


nuffcedd

Recommended Posts

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...