on ‎2013 Mar 11 2:13 AM
Greetings,
I am having an issue with using VBS to place text within shell container. Transaction CG12, create a phrase, click phrase item, then double click on your entered phrase text to open the long text editor. Trying to make script write to this word application within the SAP GUI, haven't had much luck. If you're a script master please assist. A simple subset of the code is below, simply get the focus within the window to set text using hard coded text or a variable.
Can run this script after navigating to CG12 if you like.
Sub Phrase_Load()
If Not IsObject(App) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set App = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = App.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 App, "on"
End If
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[1]/btn[18]").press
session.findById("wnd[0]/usr/ctxtRCGPHIOT-PHRGRP").Text = "GRAPHIC"
session.findById("wnd[0]/usr/txtRCGPHIOT-PHRTEXT").Text = "Jelly beans on the sidewalk"
session.findById("wnd[0]/usr/txtRCGPHIOT-PHRTEXT").SetFocus
session.findById("wnd[0]/usr/txtRCGPHIOT-PHRTEXT").caretPosition = 5
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[6]").press
session.findById("wnd[0]/usr/tblSAPLC115LG_IOTAB_CTR/txtRCGPPIOT-PHRTEXT[1,3]").SetFocus
session.findById("wnd[0]/usr/tblSAPLC115LG_IOTAB_CTR/txtRCGPPIOT-PHRTEXT[1,3]").caretPosition = 23
session.findById("wnd[0]").sendVKey 2
container_text = session.findById("wnd[0]/usr/cntlSCMSW_CONTAINER_2102/shellcont/shell").Text
'session.findById("wnd[0]/usr/cntlSCMSW_CONTAINER_2102/shellcont/shell").setDocument 1, "SAP.DocumentContainerControl.1"
End Sub
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
Dear Kirk,
One way you can try is using Appactivate and SendKeys i.e.
Appactivate("Change text") 'the windows title bar text.
SendKeys "the text to paste"
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.