Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Saturday, 18 February 2017

How to open a text file using VBScript or How to open a flat file using VBScript


Open text file can be opened using "Scripting.FileSystemObject"


OpenTextMode represents the File Read mode and Any Text file can be opened in the following modes

ForReading  1  Open a file for reading only. You can't write to this file.
ForWriting 2 Open a file for writing.
ForAppending 8 Open a file and write to the end of the file.



Syntax

filename = "c:\sample.txt"
OpenTextMode= 2

Set OpenTextMode_Obj = Createobject("Scripting.Filesystemobject")

If OpenTextMode_Obj.FileExists(filename) = true Then
    set r1 = OpenTextMode_Obj.OpenTextFile filename,OpenTextMode
 else
    ExitTest
End If

Msgbox r1.readall()



No comments:

Post a Comment

Note: only a member of this blog may post a comment.