for appending to an existing file just send in myappend true...
Call WriteUTF8WithBOM(sometext, afile, true)
Public Function WriteUTF8WithBOM(mytext As Variant, myfullfilename As String, myappend As Boolean)
Dim fsT As Object
Set fsT = CreateObject("ADODB.Stream")
fsT.Type = 2 'Specify stream type - we want To save text/string data.
fsT.Charset = "utf-8" 'Specify charset For the source text data.
fsT.Open 'Open the stream And write binary data To the object
If myappend Then
myx = ""
fsT.LoadFromFile (myfullfilename)
myx = fsT.ReadText(-1)
'mytext = myx & mytext
End If
fsT.WriteText mytext
fsT.SaveToFile myfullfilename, adSaveCreateOverWrite
'fsT.SaveToFile sFileName, 2 'Save binary data To disk
End Function
Don't forget to add ActiveX Data Objects
It is really a great work and the way in which u r sharing the knowledge is excellent.
ReplyDeleteThanks for helping me to understand basic concepts. As a beginner in Dot Net programming your post help me a lot.Thanks for your informative article.
dot net training in velachery | dot net training in chennai
Finally someone who actually tried the code.....You included the ActiveX Reference as well.....Kudos all around and thanks
ReplyDeletenice blog....Thanks for sharing...
ReplyDeletePython training in Chennai/Python training in OMR/Python training in Velachery/Python certification training in Chennai/Python training fees in Chennai/Python training with placement in Chennai/Python training in Chennai with Placement/Python course in Chennai/Python Certification course in Chennai/Python online training in Chennai/Python training in Chennai Quora/Best Python Training in Chennai/Best Python training in OMR/Best Python training in Velachery/Best Python course in Chennai/<a
This is a good post. This post give truly quality information. Computer Hardware Networking Course
ReplyDeleteThanks, works like a charm, the main difference with print is that does not add a 0D0A at the end of each line...so it has to go manually
ReplyDelete