Hi cyberspace, I have 2 vba scripts with the same purpose, create and write to a text file. The 1st script works fine when creating and writing the file to my optical hard drive and doesn't work on my flash drive. The 2nd script works fine on both optical and flash drive.
I wonder if the issue is not related to vba coding and Nand flash memory which requires a different read-write access to data in comparaison to classic optical hard drives. *Can you confirm? * 1st script works 1/2: Sub testy() Dim fs As Object, f As Object, ts As Object Dim s As String, sTxt As String, lastr As Long Set fs = CreateObject("Scripting.FileSystemObject") fs.CreateTextFile ("Y:\test2.txt") 'Create a file Set f = fs.GetFile("test2.txt") Set ts = f.OpenAsTextStream(ForWriting, TristateUseDefault) ts.Write "Hello World" ts.Close Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault) s = ts.ReadLine msgbox s ts.Close End Sub 2nd script, works OK : Sub testz() Dim fso, txtfile Set fso = CreateObject("Scripting.FileSystemObject") Set txtfile = fso.CreateTextFile("Y:\test1.txt", True) txtfile.Write ("This is a test. ") ' Write a line. ' Write a line with a newline character. txtfile.WriteLine ("Testing 1, 2, 3.") ' Write three newline characters to the file. txtfile.WriteBlankLines (3) txtfile.Close End Sub Thanks, Pascal -- FORUM RULES (986+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com