LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excel VBA-Importing txt files with VBA

Several options he

Chip Pearson has sample code for importing (and exporting) as CSV type file
with a user specified delimiter:

http://www.cpearson.com/excel/imptext.htm import/export text files

you can turn on the macro recorder and open the file in Excel - going
through the text improt wizard specifying the appropriate settings. This
will be recorded as a single instance of the OpenText method with the
selections you made recorded as arguments to that method. If you then run
this macro, it will open the file using those settings (it won't show the
wizard).
one argument is Filename:=

You can replace the hard coded file name produced by the recorder with a
variable and populate that variable using

fName = GetOpenFilename

See help for arguments to getopenfilename. This shows the file=Open dialog
and returns your selection to the variable fname as shown in the example.
It does not open the file. You could then use the value in Fname as the
argument to OpenText.

You can also write low level file IO if you wish:

http://support.microsoft.com/support...eio/fileio.asp
File Access with Visual Basic® for Applications

This gives you maximum flexibility, but requires you to do most of the work
in writing the code.

--
Regards,
Tom Ogilvy


"pwdiaz " wrote in message
...


Hi All!

I need to write a procedure that will import txt files into Excel. The
procedure, when called upon, must allow the user to select the text
file. These txt files contain data from instruments such as
spectrophotometers, luminometers etc and are typically written in row
and column formats using various delimiters depending on the machine
that generated them. Some txt file outputs are in tab deliminted
format others are in csv etc. Generally the data is in either an 8x12
or 16x24 matrix or array if you prefer, representing the format of the
original microplate from which the data are derived. All I need is a
tip or example code that will allow the automated import of the
selected text file with each element of the matrix or array to appear
in discrete cells of the work sheet. I am by necesssity working
directly with text files rather than a database so hopefully someone
has a solution that can do the import directly from the text file.

Thanks!

Paul


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



 
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 CVS files into Excel summerelli Excel Discussion (Misc queries) 2 August 31st 09 03:14 AM
Importing a Value from many Excel Files STOVK Excel Discussion (Misc queries) 2 September 25th 06 02:23 AM
Importing Files into Excel [email protected] Excel Discussion (Misc queries) 2 June 27th 06 06:43 PM
Importing CSV files into Excel Doug Excel Discussion (Misc queries) 9 August 24th 05 08:22 PM
importing files into excel Gabby Excel Discussion (Misc queries) 2 January 13th 05 09:41 PM


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