#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default text files

Is it possable to extract the data held within text files on the hard drive
directly into a worksheet through VBA.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default text files


Think I have sort of worked it out myself, however could someone explain
what "EOF(1)" is all about, and do i really have to do this one char at a
time. Also, how much info could be got using this method (obviously i would
not be putting it into a msgbog)

Sub getInfo()

Dim q, theData
Open "c:\Active\temp\testfile.txt" For Input As #1
Do While Not EOF(1)
q = Input(1, #1)
theData = theData & q
Loop
Close #1
MsgBox theData

End Sub


Stuart wrote in message
...
Is it possable to extract the data held within text files on the hard

drive
directly into a worksheet through VBA.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default text files

In Excel 2000 and later, you can do Data=Get External Data = Import Text
file.

Turn on the macro recorder while you do it manually to get the code you
need.

In earlier versions you can use low level file io or you can open it as a
new workbook, copy it across, then close the original file without saving.

--
Regards,
Tom Ogilvy

Stuart wrote in message
...
Is it possable to extract the data held within text files on the hard

drive
directly into a worksheet through VBA.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default text files

EOF is end of file.

You could actually read it all in, all at once.

However, it depends on how you want to process it.

will each line in the text file be spread over multiple columns, or does all
the data in each line go in a single cell.

If the latter, you might want to use line input

--
Regards,
Tom Ogilvy

Stuart wrote in message
...

Think I have sort of worked it out myself, however could someone explain
what "EOF(1)" is all about, and do i really have to do this one char at a
time. Also, how much info could be got using this method (obviously i

would
not be putting it into a msgbog)

Sub getInfo()

Dim q, theData
Open "c:\Active\temp\testfile.txt" For Input As #1
Do While Not EOF(1)
q = Input(1, #1)
theData = theData & q
Loop
Close #1
MsgBox theData

End Sub


Stuart wrote in message
...
Is it possable to extract the data held within text files on the hard

drive
directly into a worksheet through VBA.






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
Files saved as csv files are actually saved as text files? Queen_Of_Thebes[_2_] Excel Discussion (Misc queries) 2 May 19th 09 03:04 PM
Text Files KarenW Excel Discussion (Misc queries) 2 March 27th 09 11:19 AM
Excel (xls) files spontaneously converting to text files Be-jamin Excel Discussion (Misc queries) 0 November 18th 08 05:31 PM
Text Files Chris Excel Discussion (Misc queries) 1 June 13th 07 02:34 PM
how do i convert text files into CSV files? airpr23 Excel Discussion (Misc queries) 2 February 28th 07 12:56 AM


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