VBScript or HP ALM APIs do not offer a class or method for getting a file path from a user.
Therefore we have to use a workaround, which consists in using a different application to display a file picker dialog to a user.
A very simple solution would be to provide a user with an InputBox, which is unsatisfactory for me. Also users have to type or copy a path correctly, which they are sometimes not capable of.
I choose to automate Microsoft Excel to display a file picker dialog to a user.
This method uses the function GetOpenFileName of the Excel.Application object, which displays a file picker to a user.
' @Author - Alexander Bolte ' @ChangeDate - 2014-12-18 ' @Description - Prompts a file picker dialog to user ' and returns the file path to picked file. ' @Param myDir - a Srting providing a path to a start directory to choose files from. ' @Param myFilter - a filter String for filtering only files of specific file types. ' @Param title - a caption for the displayed file picker dialog. ' @Returns - an empty String, if user aborts file selection. ' Automates following applications: ' Microsoft Excel - using file picker dialog from Excel, ' since VBScript does not provide one. Function GetFilePath(myDir, myFilter, title) ' As String Dim xlApp ' As Excel.Application Dim ret ' As String Dim shell ' As WScript.Shell On Error Resume Next Set shell = createObject("WScript.Shell") Set xlApp = createObject("Excel.Application") xlApp.visible = True If myFilter = "" Then myFilter = "All Files (*.*), *.*" End If shell.AppActivate "Microsoft Excel" ret = xlApp.GetOpenFilename(myFilter, , title) If ret = False Then ret = "" End If If Err.Number <> 0 Then MsgBox Err.Description Err.Clear End If ' Close extra instance of Excel and set Application object to null ' to avoid "Raiders of lost reference". xlApp.Quit Set xlApp = Nothing Set shell = Nothing GetFilePath = ret On Error GoTo 0 End Function
The object called shell is of type WScript.Shell and is used to ensure that the application Excel is displayed in font of all other currently open application windows.
This way a user sees that the tool is requesting him to open an Excel file. Thus the bold lines are not essential for this code to work as expected but it will be a lot more user friendly.
Referenced APIs are as follows.