Pages

Tuesday, 18 October 2011

Import a data sheet into your test at runtime.


' =============================================================
' function: ImportDataSheet
' desc : Imports a single data sheet
' params : strFile - full path of the xls file with the sheet
' strSource - name of the sheet on the xls
' strTarget - name of the sheet to import it to
' returns : void
' =============================================================

Function ImportDataSheet(strFile, strSource, strTarget)

 

Dim objFS

 

' create a file system object
Set objFS = CreateObject("Scripting.FileSystemObject")

 

' check that the source file exists
If objFS.FileExists(strFile) Then

 

    ' ensure that our target sheet exists
    DataTable.AddSheet strTarget

 

    ' import the sheet
    DataTable.Importsheet strFile, strSource, strTarget

 

Else

 

    ' fail if the xls was not found
    Reporter.ReportEvent micFail, "Import Data Table""Unable to Import Data Table From '" & strFile & "', File Does Not Exist"

 

End If

 

' destroy the object
Set objFS = Nothing

 

End Function 'ImportDataSheet


0 comments:

Post a Comment