Quantcast
Channel: SCN : All Content - Scripting Languages
Viewing all articles
Browse latest Browse all 522

Pasting filename in a panel using script

$
0
0

Hi Experts - I ran into a problem when trying to feed a filename into an open file dialog. I used this approach in the past with an "Open" dialog and thought same would work for "Import file" dialog box.

 

My main script is below:

 

If Not IsObject(application) Then

   Set SapGuiAuto  = GetObject("SAPGUI")

   Set application = SapGuiAuto.GetScriptingEngine

End If

If Not IsObject(connection) Then

   Set connection = application.Children(0)

End If

If Not IsObject(session) Then

   Set session    = connection.Children(0)

End If

If IsObject(WScript) Then

   WScript.ConnectObject session,     "on"

   WScript.ConnectObject application, "on"

End If

 

session.findById("wnd[0]").maximize

session.findById("wnd[0]/tbar[0]/okcd").text = "/niw32"

session.findById("wnd[0]").sendVKey 0

OrdNum = "7237602"

set Wshell = CreateObject("WScript.Shell")

session.findById("wnd[0]/usr/ctxtCAUFVD-AUFNR").text = OrdNum

session.findById("wnd[0]").sendVKey 0

session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"

session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_PCATTA_CREA"

 

'>>> these 2 lines above bring up the dialog box <<<<<

 

Wshell.run "c:\tmp\Scandf.vbs",1,False

 

'>> after the filename is dropped in the dialog box by the Scandf.vbs script it should continue with the process  <<

 

session.findById("wnd[0]/usr/subSUB_ALL:SAPLCOIH:3001/ssubSUB_LEVEL:SAPLCOIH:1100/subSUB_KOPF:SAPLCOIH:1102/btn%#AUTOTEXT001").press

session.findById("wnd[1]/usr/sub:SAPLBSVA:0201[1]/chkJ_STMAINT-ANWSO[0,0]").selected = true

session.findById("wnd[1]/usr/sub:SAPLBSVA:0201[1]/chkJ_STMAINT-ANWSO[0,0]").setFocus

session.findById("wnd[1]/tbar[0]/btn[0]").press

session.findById("wnd[0]/tbar[0]/btn[11]").press

 

I am calling a script called Scandf.vbs where I have the filename I want to drop into the dialog box. This is the Scandf.vbs:

 

If Not IsObject(application) Then

Set SapGuiAuto = GetObject("SAPGUI")

Set application = SapGuiAuto.GetScriptingEngine

End If

If Not IsObject(connection) Then

Set connection = application.Children(0)

End If

If Not IsObject(session) Then

Set session = connection.Children(0)

End If

If IsObject(WScript) Then

WScript.ConnectObject session, "on"

WScript.ConnectObject application, "on"

End If

set Wshell = CreateObject("WScript.Shell")

MsgBox "in sub"

Do

bWindowFound = Wshell.AppActivate("Import file")

WScript.Sleep 1000

Loop Until bWindowFound

bWindowFound = Wshell.AppActivate("Import file")

if (bWindowFound) Then

Wshell.appActivate "Import file"

WScript.Sleep 100

Wshell.sendkeys "c:\EQ2814.txt"

WScript.Sleep 100

Wshell.sendkeys ""

end if

 

EQ2814.txt is the filename I want to drop in.

 

THe cursor is in the filename field and waiting for input. It just sits there after the dialog box is called and does not drop in the filename.

 

Can anybody see what I am doing wrong?

 

Thanks

 

Umur


Viewing all articles
Browse latest Browse all 522

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>