自动化你的测试一

2018-04-26  本文已影响0人  ww4u

利用EXCEL + VBA 进行遍历测试

举个实际的例子

 示例:要输出的文件名 输入点坐标集(X,Y,Z,END,Time,Mode) 输入点数    插值步长 轨迹规划模式 
      "Result.csv"   250 0 512 0 0 1 250 0 212 0 30 1  2        2        0

附:VBA代码

Function genItem(lineN As Long, actSheet As Worksheet)
    Dim fullPath As String
    Dim fileName As String
    Dim inputPara As String
    Dim shellArg As String
    
    Dim i As Integer

    fileName = ThisWorkbook.Path + "\output\file" + CStr(lineN) + ".csv"
    
    fullPath = ThisWorkbook.Path + "\\" + "TrajectoryManager.exe"
    
    inputPara = fileName
    For i = 1 To 15
        inputPara = inputPara + " " + CStr(actSheet.Cells(lineN, i))
    Next i
    
    shellArg = fullPath + " " + inputPara
    
    Shell (shellArg)
    'Debug.Print (shellArg)
    
    'Sleep (5000)
    
    genItem = "file" + CStr(lineN) + ".csv"

End Function

Sub genInterp()

    Dim i As Long
    Dim actSheet As Worksheet

    Set actSheet = ThisWorkbook.ActiveSheet
    
    For i = 2 To 1000
    
    If (actSheet.Cells(i, "A") <> "") Then
    
        With Range(actSheet.Cells(i, "A"), actSheet.Cells(i, "Q"))
            .Interior.Color = vbYellow
        End With
    
        actSheet.Cells(i, "Q") = genItem(i, actSheet)
        
        With Range(actSheet.Cells(i, "A"), actSheet.Cells(i, "Q"))
            .Interior.ColorIndex = xlNone
        End With
        
    End If
    
    Next i

    Set actSheet = Nothing

End Sub
上一篇 下一篇

猜你喜欢

热点阅读