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").Close
End Function

相关文章:

  • 2021-12-22
  • 2021-11-28
  • 2021-09-21
  • 2021-11-13
  • 2021-10-03
  • 2021-09-29
  • 2021-12-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-29
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
相关资源
相似解决方案