What do you mean dumping as often as possible? The code provided is not going to write to excel until you have ended the while loop. In which time you may have pressed your "Button" n amount of times. Also, because you're using Tick Count as your source of time stamp, remember that it counts in ms. So you'll need to do something to your values if you want them to represent seconds. You also menitoned a text file. I see no text file.