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: 8
Default Run-time error 1004

I am using the following to retreive the name of a file that i wish to open.
If i select 'Cancel' rather than a file name and 'Open', i would receive a
Run-time error 1004. I am handling this potential error using the ErrorClose
routine to allow me to 'Retry'. If i select the option to retry and then
elect not to open a file for a second time i receive the Run-time error 1004
message which is not handled by the ErrorClose.

Why would the error be handled as expected on the first pass but not on the
second?

Thanks



Step1:

RawDataFileInfo = "Excel Files (*.xls),*.xls," & _
"Excel Files (*.xlsx),*.xlxs"
RawDataFilterIndex = 1
RawDataTitle = "Select Raw Data File to Import"
RawDataFileName = Application.GetOpenFilename(RawDataFileInfo,
RawDataFilterIndex, RawDataTitle)
On Error GoTo ErrorClose


"Rest of Code" .............................


Exit Sub

ErrorClose:

If Err.Number = 1004 Then
ErrMsg = "You must select an Outstanding Stock Order to import" &
vbNewLine & vbNewLine
ErrReply = MsgBox(ErrMsg, vbExclamation + vbRetryCancel, "Invalid
Action")
If ErrReply = vbRetry Then
GoTo Step1
Else
Application.ActiveWorkbook.Close
End If
End If

End Sub
 
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
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Run Time Error 1004: Application or Object Defined Error BEEJAY Excel Programming 4 October 18th 06 04:19 PM
Run Time 1004 Error: Application or Object Difine Error BEEJAY Excel Programming 0 October 17th 06 10:45 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Run time error 1004 General ODCB Error Kevin Excel Programming 3 February 26th 05 12:51 PM


All times are GMT +1. The time now is 02:24 PM.

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

About Us

"It's about Microsoft Excel"