Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Open dialogue box and importing text files


Hi,

I am designing a macro that displays an Open dialogue box that asks a
user to select a filename to open (in this case it’s a text file that I
am importing into Excel)

Application.Dialogs(xlDialogOpen).Show

I need help with the code that comes after the file is selected and the
user selects open. How to I ensure that the correct column settings
(it's a fixed width import) are applied and the file continues to
open?

At present when the user selects “Open” the Import Wizzard come up. I
need this part to be automated.

I can do all of the above using an Importbox but would rather use the
dialogue box.

Hope this all makes sense!

Regards
Garry


--
Gazzr
------------------------------------------------------------------------
Gazzr's Profile: http://www.excelforum.com/member.php...o&userid=31075
View this thread: http://www.excelforum.com/showthread...hreadid=513413

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Open dialogue box and importing text files

dim myFileName as variant
myfilename = application.getopenfilename("Text Files, *.txt")
if myfilename = false then
'user hit cancel
exit sub '??
end if

Workbooks.OpenText Filename:=myFileName, .....

If you record a macro when you open the text file, you'll see all the stuff that
determines how each field is laid out.

You can add this little portion to your code (so that your recorded filename can
be removed).

Gazzr wrote:

Hi,

I am designing a macro that displays an Open dialogue box that asks a
user to select a filename to open (in this case it’s a text file that I
am importing into Excel)

Application.Dialogs(xlDialogOpen).Show

I need help with the code that comes after the file is selected and the
user selects open. How to I ensure that the correct column settings
(it's a fixed width import) are applied and the file continues to
open?

At present when the user selects “Open” the Import Wizzard come up. I
need this part to be automated.

I can do all of the above using an Importbox but would rather use the
dialogue box.

Hope this all makes sense!

Regards
Garry

--
Gazzr
------------------------------------------------------------------------
Gazzr's Profile: http://www.excelforum.com/member.php...o&userid=31075
View this thread: http://www.excelforum.com/showthread...hreadid=513413


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Open dialogue box and importing text files


Excellent Dave,

Thanks for your help. I should be able to work it out from here.

Garr

--
Gazz
-----------------------------------------------------------------------
Gazzr's Profile: http://www.excelforum.com/member.php...fo&userid=3107
View this thread: http://www.excelforum.com/showthread.php?threadid=51341

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
Importing text-files GARY Excel Discussion (Misc queries) 6 December 13th 06 02:57 PM
Importing Text Files smith_gw Excel Discussion (Misc queries) 1 May 5th 05 10:42 PM
Importing text files Dominique Feteau[_2_] Excel Programming 1 December 16th 04 12:25 PM
Importing data from text files Jeff Armstrong Excel Programming 3 October 28th 03 01:35 AM
importing text files msweeney Excel Programming 3 September 24th 03 01:49 AM


All times are GMT +1. The time now is 12:30 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"