cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

VBS Input Data Into Shell Container (Long Text Editor)

Former Member
0 Likes
3,484

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

View Entire Topic
Former Member
0 Likes

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.