Friday 7 February 2014

How to write the string(unicode) to textfile

Set fs = CreateObject("Scripting.FileSystemObject")

dlgSaveAsString = Application.GetSaveAsFilename("ABCD.txt", FileFilter:="text file (*.txt),*.txt")

If (dlgSaveAsString <> False) Then
    Set a = fs.CreateTextFile(dlgSaveAsString, True, True)
    a.writeline (kmlText)
    a.Close
End If

for more details: please check the below text and link

CreateTextFile Method
See Also    Example    Applies To    Specifics
Description
Creates a specified file name and returns a TextStream object that can be used to read from or write to the file.
Syntax
object.CreateTextFile(filename[, overwrite[, unicode]])
The CreateTextFile method has these parts:

Part
Description
object
Required. Always the name of a FileSystemObject or Folder object.
filename
Required. String expression that identifies the file to create.
overwrite
Optional. Boolean value that indicates if an existing file can be overwritten. The value is True if the file can be overwritten; False if it can't be overwritten. If omitted, existing files are not overwritten.
unicode
Optional. Boolean value that indicates whether the file is created as a Unicode or ASCII file. The value is True if the file is created as a Unicode file; False if it's created as an ASCII file. If omitted, an ASCII file is assumed.


http://msdn.microsoft.com/en-us/library/aa265018(v=vs.60).aspx