Hi Folks
I have an Excel Macro that looks for 4 files and modifies them like this :
Problem is that if F1 is NOT present , it ends with error.I'd like to do something so that , whether F1 is found or not it will STILL check for F2 ..F4 . Same stuff for F2..F4Code: Workbooks.Open Filename=F1 # progam code here ActiveWorkbook.Save ActiveWorkbook.Close Workbooks.Open Filename=F2 # progam code here ActiveWorkbook.Save ActiveWorkbook.Close
Finally I would like to Rename the file with this naming convention
Rename F1xls to YYYYMMDD_F1.xls
then invoke a zip program ( Its already there in my directory called zip.exe and i know the command line arguments to it ) to zip each file.
Thank You ,so so ,much
Hi sieger007
See this link to check for existence of file or folder http://www.excelguru.ca/node/30
Or you could tryOn Error Resume Next 'Your Code On Error Goto 0
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
Maybe like this:
Sub x() Const sPath As String = "C:\myPath\" ' note trailing "\" Dim vsFile As Variant For Each vsFile In Array("F1.xls", "F2.xls", "F3.xls") If Len(Dir(vsFile)) Then With Workbooks.Open(Filename:=sPath & vsFile) ' code here .Close SaveChanges:=True Name sPath & vsFile As sPath & Format(Date, "yyyymmdd_") & vsFile End With End If Next vsFile End Sub
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks