|
大家好!
我在网上找了一个qtp自动化写文件的脚本,我在QTP8.0里运行了脚本后,运行到 Set fso = CreateObject("scrīpting.FileSystemObject") 这步就报错,
报错内容:ActivateX部件不能创建对象:"scripting.FileSystemObject"错误
请问大家,这是什么原因,怎么解决,谢谢了
网上找的写文件脚本如下:
Dim txtapp
Set txtapp = CreateFile("d:/qtp.txt",true) '返回TextSream.
WriteToFile "d:/qtp.txt" ,"this is the fist line" '是把路径传给了 WriteToFile.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function CreateFile(sFile, bOverwrite)
Set fso = CreateObject("scrīpting.FileSystemObject")
set CreateFile = fso.CreateTextFile(sFile, bOverwrite) '返回TextSream
CreateFile.close '注意 一定要关闭。否则下次打开的时候,就不能写入
End Function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function WriteToFile(sFilename, sLine)
Dim getf
Dim f
Const ForWriting = 2
Set fso = CreateObject("scrīpting.FileSystemObject")
set getf =fso. getfile(sFilename) '返回 file object ,这时进来的是 path
Set f =getf.OpenAsTextStream( ForWriting,-2) '返回text sream
f.Write sLine
f.Close
End function |
|