Fill text in selected field from active window - VBScript, WScript.Shell

818 Views Asked by At

I use vbs to upload files into SAP. After clicking "add file" in sap I have the following window on the screen.

popup window

I can't control that window using SAP Object so I use WScript.Shell. My question is - how to paste text (file path) to the field "File name:"? I was using wshShell.SendKeys "{TAB}" to jump from one field to another and paste file path, but somehow it doesn't work always. How to get control over that field "File name:" directly and edit it's value?

My code here:

Set wshShell = CreateObject("WScript.Shell")
filePath = "C:\image.png"

wshShell.AppActivate("Storing Files in Documents")
  WScript.sleep 200
wshShell.SendKeys "{TAB}"
  WScript.sleep 200
wshShell.SendKeys filePath
  WScript.sleep 200
wshShell.SendKeys "{ENTER}"
WScript.Quit

Regards

0

There are 0 best solutions below