Well in that case I've got no idea what the problem is... so I'd recommend Marty's suggestion of using an alternative to FSO, which could be like this:
Note that due to the keywords For Output the files will be replaced each time. If you want to add to the end of the SPC_Data file instead of replacing it, change For Output to For AppendCode:Public Sub AutoWriteDispData() Dim strThisTime As String Dim intFileNum As Integer On Error GoTo FileError: ' write file with time date stamp unique name strThisTime = Format(Now, "mm_dd_yyyy_____Hh_mm_ss") intFileNum = FreeFile Open "C:\CES\XRF_Control\Data_Files\" & strThisTime & ".txt" For Output As #intFileNum Print #intFileNum, gblstrAcquisitionFileData Close #intFileNum intFileNum = FreeFile Open "C:\SPCData\SPC_Data.txt" For Output As #intFileNum Print #intFileNum, gblstrAcquisitionFileData Close #intFileNum Exit Sub FileError: MsgBox " FATAL ERROR WRITING DATA FILES ! " & " Error Description = " & Err.Description & " Error Number = " & _ Err.Number '(removed Err.Clear, as it doesn't do anything useful in cases like this) Close #intFileNum 'this is safe in an error handler, as it will be ignored if the file number is not open End Sub




Reply With Quote