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
End Sub


1 Comment »

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

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s