By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,780 Members | 1,126 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,780 IT Pros & Developers. It's quick & easy.

Reading text file into excel automatically

P: 2
How do i read a text file into excel automatically anytime the text file is updated. I have a text file that is updated every 100 times a minute from the hyperterminal text capture. I want to read it into excel 100 times a minute?
Nov 21 '06 #1
Share this Question
Share on Google+
4 Replies


Expert 5K+
P: 8,434
How do i read a text file into excel automatically anytime the text file is updated. I have a text file that is updated every 100 times a minute from the hyperterminal text capture. I want to read it into excel 100 times a minute?
Were you thinking of driving this from within Excel, or from a separate application, or what?
Nov 21 '06 #2

Expert 5K+
P: 8,434
At the simplest level, I suppose you could have a VBA macro in Excel which just keeps looping, issuing DoEvents to allow other things to happen, and checking the file once every however-often.

Here's something off the top of my head...
Expand|Select|Wrap|Line Numbers
  1. Public Sub DoSomething()
  2.   Const TimesPerSecond As Double = 100
  3.   Dim Interval As Double
  4.   Dim WaitUntil As Double
  5.   Interval = TimeValue("00:00:01") / TimesPerSecond
  6.   Do
  7.     WaitUntil = Now() + Interval
  8.     Do
  9.       DoEvents
  10.     Loop Until Now >= WaitUntil
  11.     ' Do your thing here...
  12.     Beep
  13.   Loop
  14. End Sub
There are probably heaps of things wrong with this, but it should be enough to illustrate the idea, anyway.
Nov 21 '06 #3

P: 2
Thanks for the reply.I still have a little problem, I have not programmed with visual basic before but i need this for a small project. Is it possible for me to get a complete code of how I could load a text file, say ggg.txt 100 times per second into excel. That is anytime the file is updated it is uploaded into excel.

At the simplest level, I suppose you could have a VBA macro in Excel which just keeps looping, issuing DoEvents to allow other things to happen, and checking the file once every however-often.

Here's something off the top of my head...
Expand|Select|Wrap|Line Numbers
  1. Public Sub DoSomething()
  2.   Const TimesPerSecond As Double = 100
  3.   Dim Interval As Double
  4.   Dim WaitUntil As Double
  5.   Interval = TimeValue("00:00:01") / TimesPerSecond
  6.   Do
  7.     WaitUntil = Now() + Interval
  8.     Do
  9.       DoEvents
  10.     Loop Until Now >= WaitUntil
  11.     ' Do your thing here...
  12.     Beep
  13.   Loop
  14. End Sub
There are probably heaps of things wrong with this, but it should be enough to illustrate the idea, anyway.
Nov 27 '06 #4

Expert 5K+
P: 8,434
Thanks for the reply.I still have a little problem, I have not programmed with visual basic before but i need this for a small project. Is it possible for me to get a complete code of how I could load a text file, say ggg.txt 100 times per second into excel. That is anytime the file is updated it is uploaded into excel.
I think you need to be more specific about what you mean by "loaded". For example, if you were going to load it manually, would you
  • Simply open the file in Excel?
  • Paste the text over the top of existing data, replacing it?
  • Append the the text onto the end of existing data?
  • Load the text into a new worksheet within an existing workbook?
There are just too many options for the "what" for us to start advising you on the "how".
Nov 27 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.