Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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
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
When opening a file in 2003 it gives a look in option-Where n 200. herbwj Excel Discussion (Misc queries) 1 April 1st 10 11:54 PM
Cancel opening messages/phantom link issue J.W. Excel Discussion (Misc queries) 3 August 14th 07 07:36 PM
No option to password protect opening an excel / word file Andy Excel Discussion (Misc queries) 1 June 20th 05 03:54 PM
How do I turn on the Last Modified option when opening a file? WomensHealthUSA Excel Discussion (Misc queries) 0 June 8th 05 02:31 PM
Option to continue or cancel Ken G[_2_] Excel Programming 3 June 7th 04 04:13 AM


All times are GMT +1. The time now is 09:35 AM.

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

About Us

"It's about Microsoft Excel"