Public Function QTP_Change_Color(pathway,sheetname,x,y,color)
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 If color = "red" Then srcDoc.Worksheets(sheetname).Cells(x,y).Interior.color=vbred ElseIf color = "green" Then srcDoc.Worksheets(sheetname).Cells(x,y).Interior.color=vbgreen Else MsgBox "输入的颜色参数不正确,只接收""red""和""green""" End If Dim WshShell Set WshShell=CreateObject("Wscript.Shell") WshShell.SendKeys "^s" wait(1) srcData.Workbooks.Close Set srcDoc = nothing Window("text:=Microsoft Excel").CloseEnd Function