Attribute VB_Name = "WriteRead" Public DataArray() As Integer Sub macro1() Dim FilePath As String Dim FileNm As String Dim MyString As String FileNm = "WestSpiel20180101_20180717_0231" MyString = "Get ready to read Wiesbaden files Still!" FilePath = "c:\users\still\desktop\" & FileNm & ".txt" 'Debug.Print FilePath bOut = AppendStringToFile(MyString, FilePath) ' End Sub Sub Macro2() Dim bOut Dim FileNm As String FileNm = "c:\users\still\desktop\test.txt" bOut = ReadLine(FileNm, 14) Debug.Print bOut End Sub Sub Macro3() Dim nOut As Integer Dim FileNm As String FileNm = "c:\users\still\desktop\test.txt" nOut = CountLines(FileNm) Debug.Print nOut End Sub Function CountLines(File) 'If WhichLine = 0 then it will return last line 'If WhichLine > number lines in file, will return number of lines as a string Dim Count As Long Dim N Count = 0 N = FreeFile Open File For Input As #N Do While Not EOF(N) Count = Count + 1 Line Input #N, strLine Loop Close CountLines = Count End Function Function ReadLine(File, WhichLine) 'If WhichLine = 0 then it will return last line 'If WhichLine > number lines in file, will return number of lines as a string Dim N Dim F Dim Count Dim strStringOut As String Dim strLine Count = 0 N = FreeFile Open File For Input As #N Do While Not EOF(N) Count = Count + 1 Line Input #N, strLine If Count = WhichLine Then strStringOut = strLine Loop Close If WhichLine = 0 Then ReadLine = strLine ElseIf WhichLine > Count Then ReadLine = "There are only " & Count & " lines in " & File Else ReadLine = strStringOut End If End Function Public Function AppendStringToFile(ByVal Data, Filename) As Boolean Dim F 'open a new file for output 'and print to it F = FreeFile Open Filename For Append As #F Print #F, Data Close #F AppendStringToFile = True End Function