Steve
My CSV files come from an analyzer -- and it comes as flat ASCII files --- so I appreciate your comments about using a table -- but not applicable here --- I dont think. My timer is actually set to 6 seconds --- so evey 6 seconds I go look for ASCII files -- what I found was that if the device had been running --- But xl 2007 not open -- I would have hundreds of ASCII files to process. The way my code works is as follows
0) Creates an array all ASCII file names
1) Opens and reads ASCII file content into a dynamic array --- using the split command - one file at a time
2) Closes the file
3) Places the file content into my worksheet
4) Kills the ASCII file - I process files one at atime -- to protect from data loss.
6) If NOT all files processed -- I repeat from step 1
What happens is the I get an error when I try to Kill the file --- however if I use the Sleep 500 before I execute the Kill command -- the code has time to execute (This only happens when I have a large number of files to process) --- I think it is some sort of file sharing violation -- but I dont know for sure. The 500 MS may be a long pause --- but I think the time depends on the CPU speed and how fast the hard disk is accessed --- so since I only get new data every 6 seconds -- I have time to spare (except when large number files). I also keep track of when the workbook.save was executed -- as I have a variable that allows the user to autosave the workbook every so many minuttes. Since I add a new row to the worksheet every 6 seconds -- the worksheet rapidly become large.
Yes -- The DoEvents command appears to stop xl2007 from freezing ---- however all my xl2007 icons are greyed out --- even the office button -- but when I stop my timer it become active again.
So I am puzzled --- but it is a bit odd and I am not really sure why it all works.
Your feed back is most appreciated as I would like to understand my code - lol
I now use -- my own manual timer --- DoEvents & the Windows API Sleep ------ so really crazy.
Code:Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Sub Somecode Sleep 500 End Sub







Reply With Quote
Bookmarks