Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1092861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:44:43+00:00 2026-05-16T23:44:43+00:00

Our Team is automating tests/test data preparation in QTP and we do the scripting

  • 0

Our Team is automating tests/test data preparation in QTP and we do the scripting in VBScript.

In several tests the tester who runs the script need to supply an MS-Excel file with the indata. We use UserAccounts.CommonDialog for this and it works great. Except for one litle problem, when we run this from QTP the file dialog does not get focus. It’s opened in the background and it’s easy for the tester that runs the script to miss it and waste time waiting for the dialog.

How do we give the file dialog focus?

Code Example:

Set ObjFSO = CreateObject("UserAccounts.CommonDialog") 
ObjFSO.Filter = "MS-Excel Spreadsheets|*.xls|All Files|*.*" 

while ObjFSO.ShowOpen = false 
    msgbox "Script Error: Please select a file!"
wend

msgbox "You selected the file: " & ObjFSO.FileName
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:44:43+00:00Added an answer on May 16, 2026 at 11:44 pm

    My guess is that since the dialog is modal, the ShowOpen method doesn’t return the execution control back to the script until the dialog is closed. So there’s no way to interact with the dialog as part of your test script.

    As a workaround, you could spawn a parallel script that would wait for the dialog and activate it. But I guess QTP cannot run two scripts in parallel, so you’ll probably need an external shell script (written in VBScript / JScript / PowerShell / etc).


    Edit: Try the following:

    • Create an external VBScript file (.vbs) with the following contents:

      Set oShell = CreateObject("WScript.Shell")
      While Not oShell.AppActivate("Open")
        WScript.Sleep 500
      Wend
      

      This script calls WshShell.AppActivate to activate a window whose title contains Open (replace it with the actual dialog title). If there’s no such widnow at the monent, it retries the attempt after 0.5 sec (you can increase the delay if you wish).

    • Launch this script from your QTP test before opening the dialog. (Use SystemUtil.Run or something like this.)

    I’m not sure, but I think this should do the trick.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our team has recently been working on a logic and data layer for our
My automatic test-framework tests a bunch of Excel sheets required by our customers with
What are the best methods for tracking and/or automating DB schema changes? Our team
Our team is now beginning to look at jumping from 2.0 to 3.5 and
Our team builds and owns a webservices framework. Other teams which actually build the
Our team is just ramping up to use source control through SVN. We are
Our team recently upgraded to TeamCity 4.5.4 but we're having trouble with TeamCity running
Our team is currently working on a large project which makes heavy use of
Our team has just started developing for the Sitecore CMS. We find that after
Our Team Foundation Server has to build three different versions of the same solution.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.