Write or Append a Text File

by Selva V Pasupathy

Attribute VB_Name = "Write_or_Append"
Option Explicit

Sub test1()
     Call OpenTextFileTest("selva v pasupathy", "myTextFile.txt")
End Sub

Sub OpenTextFileTest(txtString, myfile)
     Const ForReading = 1, ForWriting = 2, ForAppending = 3
     Dim fs, f As Object, myfilepath As String

     Set fs = CreateObject("Scripting.FileSystemObject")
     Set f = fs.OpenTextFile(ThisWorkbook.Path & "\" & myfile, 8, True)

     f.Writeline txtString
     f.Close
End Sub

1 Comment »

  1. [...] Write or Append a Text File [...]

RSS feed for comments on this post · TrackBack URI

Leave a Comment

You must be logged in to post a comment.