Pages

Wednesday, 19 October 2011

QTP Script: Opens a standard dialog which allows the user to choose a file


' =============================================================
' function : FileBrowser
' desc : Opens a standard Open File Dialog 
' params : strTitle - the title to apply to the dialog
' strFilter - the filter to apply to the dialog
' returns : The selected file, including path
' =============================================================

Public Function FileBrowser(strTitle, strFilter)

Dim objDialog

 

' create a common dialog object 
Set objDialog = CreateObject("MSComDlg.CommonDialog")

 

' set the properties and display the dialog 
With objDialog
    .DialogTitle = strTitle
    .Filter = strFilter
    .MaxFileSize = 260
    .ShowOpen
End With

 

' return the selected file 
FileBrowser = objDialog.FileName

 

' destroy the object 
Set objDialog = Nothing

End Function ' FileBrowser


0 comments:

Post a Comment