VBS典型好用的測試腳本 軟件測試
調用測試程序,打開(kāi)某個(gè)指定文件夾里面所有“*.*”格式的文件,執行某些可控操作,然后存盤(pán)。
Sub testCases()
'打開(kāi)一個(gè)文件夾(包括子文件夾)中的所有doc文件,執行相同的操作。
'吳增念 測試腳本。
Dim strPath As String
Dim strFileName As String
Dim docOutline As Document
Dim strFileNames() As String
Dim lFileNames As Long
'獲取文件夾路徑
strPath = ActiveDocument.Path '(也可以指定文件夾路徑 strPath = "c:\testCase" )
'call 下面一段函數。(路徑、后綴、文件名)
lFileNames = TreeSearch(strPath, "*.doc", strFileNames())
'從第2個(gè)文件開(kāi)始執行操作
For idx = 2 To lFileNames
'/////////////////////////////////////////////////////////////////
'打開(kāi)指定文件名
strFileName = strFileNames(idx)
If Len(strFileName) Then
Set docOutline = Application.Documents.Open(strFileName)
'to do
'關(guān)閉執行后的文件,不保存。(保存:wdPromptToSaveChanges ; 取消:wdSaveChanges)
ActiveWindow.View.Type = wdWebView
Selection.Orientation = wdTextOrientationVerticalFarEast
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=4, NumColumns:=6, DefaultTableBehavior.:=wdWord9TableBehavior, AutoFitBehavior.:=wdAutoFitFixed
ActiveDocument.Shapes.Range(1).Select
文章來(lái)源于領(lǐng)測軟件測試網(wǎng) http://kjueaiud.com/