Pages

Monday, December 5, 2011

QTP Script to show the FileOpen Dialog box

Use the following code to show the standard windows open dialog box:


Set objOpenDlg = DotNetFactory.CreateInstance("System.Windows.Forms.OpenFileDialog", "System.Windows.Forms")
objOpenDlg.InitialDirectory="c:\\"
objOpenDlg.Filter="All files (*.*) |*.*"
objOpenDlg.RestoreDirectory=true
objOpenDlg.FilterIndex=2
objOpenDlg.ShowDialog()
Msgbox objOpenDlg.FileName

The OpenFileDialog methods and properties can be found here
Not necessary to have .NET Add-in selected to use this class.

No comments:

Post a Comment