Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cancel option possible while opening a file?
Hi Aiyer,
Try changing: If MyFile = "" Then to: If MyFile = False Then --- Regards, Norman " " wrote in message ... Hello! I was trying to open a file as follows, however the user needs to have a 'cancel' option as well. I.e., if the 'Cancel' button in the pop up screen is hit, it should exit the macro. I tried the following but it 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/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
When opening a file in 2003 it gives a look in option-Where n 200. | Excel Discussion (Misc queries) | |||
Cancel opening messages/phantom link issue | Excel Discussion (Misc queries) | |||
No option to password protect opening an excel / word file | Excel Discussion (Misc queries) | |||
How do I turn on the Last Modified option when opening a file? | Excel Discussion (Misc queries) | |||
Option to continue or cancel | Excel Programming |