|
我可以提供一个自己写的删除vbs的函数
'写Excel文件元素并保存退出
Public Function QTP_Write_Excel(pathway,sheetname,x,y,content)
Dim srcData,srcDoc,sp1,sp2,num,use,a1,a2,a3
set srcData = CreateObject("Excel.Application")
srcData.Visible = True
set srcDoc = srcData.Workbooks.Open(pathway)
srcDoc.Worksheets(sheetname).Activate
srcDoc.Worksheets(sheetname).Cells(x,y).value = content
sp1 = Split(pathway,".")
sp2 = Split(sp1(0),"\")
num = UBound(sp2)
use = sp2(num)
Set a1 = Description.Create()
a1("text").value="Microsoft Excel - " + use + ".xls"
a1("window id").value="0"
Set a3 = Description.Create()
a3("Class Name").value="WinObject"
a3("text").value= use + ".xls"
Window(a1).WinObject(a3).Type micCtrlDwn + "s" + micCtrlUp
srcData.Workbooks.Close
Set srcDoc = nothing
Window("text:=Microsoft Excel").Close
End Function |
|