简体   繁体   中英

how to browse and open a file on window dialog box using vb scripting

For one of the requirement, I need to click on browse button on the UI which will open up the window dialog box with title "Choose File to Upload". I need to input file name in the input box for file name and click on Open button on this window dialog. I tried the code to activate this window and to use shell script to send keys, but it's not working. Can someone please help in getting this resolved? snapshot of the window dialog

Do 
  bResult = objWshShell.AppActivate("Choose File to Upload")
  If bResult = True Then 
    oShell.SendKeys "C:\text.xls"
    oShell.SendKeys "{ENTER}"
    Exit Do 
  End If 
  WScript.Sleep 500 
Loop 

Do bResult = objWshShell.AppActivate("Choose File to Upload") If bResult = True Then oShell.SendKeys "%n" oShell.SendKeys "C:\\text.xls" oShell.SendKeys "{ENTER}" Exit Do End If WScript.Sleep 500 Loop

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM