View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
aiyer[_56_] aiyer[_56_] is offline
external usenet poster
 
Posts: 1
Default Cancel option possible while opening a file?

Hello!

I was trying to open a file as follows, however the user needs to hav
a 'cancel' option as well. I.e., if the 'Cancel' button in the pop u
screen is hit, it should exit the macro. I tried the following but i
does'nt work.
==============================================
Sub importfile()

Application.ScreenUpdating = False
Application.DisplayAlerts = False

MyFile = Application.GetOpenFilename("text files,*.txt")

If MyFile = "" Then
Exit Sub
End If

Workbooks.OpenText Filename:=MyFile, _
Origin:=xlWindows, StartRow:=1, _
DataType:=xlFixedWidth, FieldInfo:= _
Array(Array(0, 1), Array(11, 1), Array(20, 1))

endsub
==============================================

Any suggestions?

Thanks in advance.

Regds,

Arun.
Vtec Corp

--
Message posted from http://www.ExcelForum.com