Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error opening files from a list in a spreadsheet
Help! I get Run-time error 1004 when I run the following macro. I have a
list of file names (ex: 1025104902.xls) in my personal.xls that is defined by a range, say "GA". Sometimes an Excel file does not exist for a file name in this list. In this case, I want the macro to bypass the file not found error and resume the routine with the next file name in the list. Can anyone please help me with the code that will do this? Thank you. Andy Here is part of my code from it starts to where it stops: Private Sub CommandButton1_Click() ' Report CC EV 100 ' Format_100_Rpt Macro ' Macro recorded 11/8/2005 by anolasco ' ' Dim myCell Dim myRange Dim myDir As String Dim myDate As String Dim myHeader As String myRange = Application.InputBox(prompt:="Enter a Range", Type:=8) myDir = Application.InputBox(prompt:="Enter File Location", Default:="U:\CC_EV_100 Reports\mmyy\", Type:=2) myDate = Application.InputBox(prompt:="Enter Date and Time", Default:="mm/dd/yy hh:mm am", Type:=2) myHeader = Application.InputBox(prompt:="Enter As of Date", Default:="October 31, 2005", Type:=2) Windows("PERSONAL.XLS").Visible = True Workbooks("PERSONAL.XLS").Activate Sheets("Sheet1").Select For Each myCell In myRange Workbooks.Open Filename:=myDir & myCell (run-time error 1004) (In between I have code that does formatting and calcuations.) Next myCell |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error opening files from a list in a spreadsheet
Try putting On Error Resume Next just before your loop. This will bypass the error code and continue processing your code. Hope it helps. -- goober ------------------------------------------------------------------------ goober's Profile: http://www.excelforum.com/member.php...o&userid=19838 View this thread: http://www.excelforum.com/showthread...hreadid=487744 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error opening files from a list in a spreadsheet
Thank you. I will try it.
"goober" wrote: Try putting On Error Resume Next just before your loop. This will bypass the error code and continue processing your code. Hope it helps. -- goober ------------------------------------------------------------------------ goober's Profile: http://www.excelforum.com/member.php...o&userid=19838 View this thread: http://www.excelforum.com/showthread...hreadid=487744 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
opening files error | Excel Discussion (Misc queries) | |||
Opening/converting other spreadsheet programs' files | Excel Worksheet Functions | |||
Virus error opening all files | Excel Worksheet Functions | |||
data error while opening files | Excel Discussion (Misc queries) | |||
error opening .csv files | Excel Discussion (Misc queries) |