Applies To:
HPE ALM workflow
Issue:
Customer wants to select a file to save an exported test case to excel.
Solution:
'Author: Chris Carpenter
'Created: 07/07/2016
'Parameters: N/A
'Purpose: Opens a window and retreives the file system location of the excel file selected.
Function USER_SelectFile( )
Dim objExec, strMSHTA, wshShell
'Start with NULL
USER_SelectFile = ""
'Setup the window
strMSHTA = "mshta.exe ""about:" & "<" & "input type=file id=FILE>" _
& "<" & "script>FILE.click();new ActiveXObject('Scripting.FileSystemObject')" _
& ".GetStandardStream(1).WriteLine(FILE.value);close();resizeTo(0,0);" & "<" & "/script>"""
'Create WScript object
Set wshShell = CreateObject( "WScript.Shell" )
'Launch HTA
Set objExec = wshShell.Exec( strMSHTA )
'Capture the output of the file
USER_SelectFile = objExec.StdOut.ReadLine( )
'Destroy objects
Set objExec = Nothing
Set wshShell = Nothing
End Function