#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Text Files

Hey People,

Anyone know how to get the first line of data in a textfile and dump i
to a cell in Excel?

cheers
Jo

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Text Files

This should do it...

Sub bubb()

Dim strLine As String

Close
Open "c:\junk.txt" For Input As #1
Line Input #1, strLine
Range("A1").Value = strLine
Close #1

End Sub




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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Text Files

Hi Joe,

Try something like:

Sub B()
Dim FNum As Integer
Dim sLine As String

FNum = FreeFile

Open "c:\temp\test.txt" For Input Access Read As #FNum

Input #FNum, sLine
Sheets("Sheet2").Range("A1") = sLine
Close #FNum
End Sub

HTH

Peter Beach

"Joseph " wrote in message
...
Hey People,

Anyone know how to get the first line of data in a textfile and dump it
to a cell in Excel?

cheers
Joe


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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Text Files

Thats just the job,

Now is there any way to do this after a specified amount of time?

i.e. I want excel to check the size of the file after about 3 seconds
and if it finds that the file size has changed then it should outpu
the new code. I've been fiddling around with Filelen() and timer() bu
can't get my limited brain around it!

Cheer

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 70
Default Text Files

Hi Joseph,

Check out Application.OnTime. Your structure would be something like:

Private m_nNextTime as double

Sub CheckFile()
' Code to check whether the file has changed

m_nNextTime = Now + TimeValue("00:00:03")
Application.OnTime m_nNextTime, "CheckFile"
End Sub

BTW you need to store the time the routine will next run so that you can
turn off the timer at the end.

HTH

Peter Beach

"Joseph " wrote in message
...
Thats just the job,

Now is there any way to do this after a specified amount of time?

i.e. I want excel to check the size of the file after about 3 seconds,
and if it finds that the file size has changed then it should output
the new code. I've been fiddling around with Filelen() and timer() but
can't get my limited brain around it!

Cheers


---
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
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
Excel (xls) files spontaneously converting to text files Be-jamin Excel Discussion (Misc queries) 0 November 18th 08 05:31 PM
how do i convert text files into CSV files? airpr23 Excel Discussion (Misc queries) 2 February 28th 07 12:56 AM
Using text files Leho Excel Programming 1 December 11th 03 02:47 PM
text files Stuart[_12_] Excel Programming 3 December 2nd 03 01:35 AM


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