OpenFileDialog In QTP with help of DotNetFactory
Set fd = DotNetFactory.CreateInstance(“System.Windows.Forms.OpenFileDialog”, “System.Windows.Forms”)
fd.InitialDirectory=”c:\\”
fd.Filter=”txt files (*.txt)|*.txt |All files (*.*) |*.*”
fd.RestoreDirectory=true
fd.FilterIndex=2
fd.ShowDialog()
msgbox fd.FileName
Author: Mohan Kakarla
6 Comments »
Leave a comment
-
Archives
- November 2008 (4)
- October 2008 (1)
- September 2008 (2)
- June 2008 (1)
- March 2008 (4)
- February 2008 (44)
-
Categories
- Automated Test Script Creation Process
- Automating MS Word
- Automating QC
- Automation Object Model For QTP
- Backward compatability in QTP
- Browser Scripts
- COM and QTP
- compare 2 text files
- Descriptive programming
- Descriptive Programming and Child Objetcs
- Dictonary Object
- DotNetFactory
- Excel Automation
- Extra Topics
- Files and Folders
- General Standards to be followed in Test scripts
- New Features In QTP9.5
- QC-OTA
- QTP Additional Faqs
- QTP Faqs
- QTP Naming Convention
- QTP Tips and Faqs
- Running stored procedures from QTP
- Send keyboard keys
- Uncategorized
- Uninstall a software using QTP
- Uninstall a software using vbscript
- Update data in a database
- VBScript and IE Automation
- VBScript Faqs and Useful resources
- What’s New in Quick Test Pro 9.0
- Whats New in QTP 9.5
- XML Scripting
-
RSS
Entries RSS
Comments RSS

great thX!!!
I find it of great help
However I am not able to generate a list box with few values in it which will help to select a input value out of it.
However I am not able to generate a list box with few values in it which will help to select a input value out of it.
Neelesh ,
Use the following code to generate a list box with few values using dotnet factory.
Set objForm = DotNetFactory.CreateInstance(“System.Windows.Forms.Form”, “System.Windows.Forms”)
Set objBtn1 = DotNetFactory.CreateInstance(“System.Windows.Forms.Button”, “System.Windows.Forms”)
Set objList1 = DotNetFactory.CreateInstance(“System.Windows.Forms.ListBox”, “System.Windows.Forms”)
x=200
y=100
Set s1 = DotNetFactory.CreateInstance(“System.Drawing.Size”,”System.Drawing”,x,y)
x1=80
y1=40
Set p1 = DotNetFactory.CreateInstance(“System.Drawing.Point”,”System.Drawing”,x1,y1)
objList1.size=s1
objList1.Location=p1
objForm.Controls.Add(objList1)
objList1.MultiColumn=False
objList1.SelectionMode = objList1.SelectionMode.MultiExtended
objList1.BeginUpdate()
objList1.Items.Add(“India”)
objList1.Items.Add(“USA”)
objList1.Items.Add(“UK”)
objList1.Items.Add(“Canada”)
objList1.EndUpdate()
objList1.SetSelected 1, True
objBtn1.Text=”OK”
p1.Y=Cint(p1.Y)+CInt(objList1.Height)+20
objBtn1.Location=p1
objForm.CancelButton=objBtn1
objForm.Controls.Add(objBtn1)
objForm.StartPosition=CenterScreen
objForm.Text=”Mohan kakarla”
objForm.ShowDialog
msgbox objList1.SelectedItem
Let me know if it serves ur requrement
Hi Mohan,
I need some tips for designing QTP framework & creating master script. Kindly help me
Nirmal
Hi Mohit,
i tried the code above in the page to get the file open dialog box at run time allowing user to select the file he wants to open. My script hangs on the line “fd.ShowDialog()” and then i have to forcefully close it from task manager. please revert me on shekhar.sharma@headstrong.com in this regards.
thanks,
Shekhar