Skip to Content
0

Copying second level Container text - Sendkeys?

Jul 10, 2017 at 01:53 PM

78

avatar image

Hi there,

I'm very new to coding SAP through scripts so apologies if there is a really obvious answer to this. I've tried using the record function to capture what I want to do but it doesn't capture me copying the text using the keyboard so I was wondering if there was another way..... here is what I have so far.

session.FindById("wnd[0]").SendVKey 0
session.FindById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").DoubleClickCurrentCell
session.FindById("wnd[0]/tbar[1]/btn[5]").Press
session.FindById("wnd[0]/usr/shell/shellcont[1]/shell[1]").SelectItem " 2", "&Hierarchy"

Everything works great up until this point and does exactly as it should. What I want to do next is copy the contents of the selected item. I can do this easily by using CTRL-C on the keyboard but I can't find the proper way of either using sendkeys or allocating the text to a variable such as..

variable1 = session.FindById("wnd[0]/usr/shell/shellcont[1]/shell[1]").SelectItem " 2", "&Hierarchy"

session.FindById("wnd[0]/usr/shell/shellcont[1]/shell[1]").SendVKey V92

Both options give errors though.

Many thanks in advance for any assistance.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Stefan Schnell
Jul 13, 2017 at 08:20 AM
0

Hello Scott,

try this to copy the content of an active cell to the clipboard.

CurrCellRow = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").CurrentCellRow()
CurrCellCol = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").CurrentCellColumn()
CurrCellContent = session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell/shellcont[1]/shell").GetCellValue(CurrCellRow, CurrCellCol)

Set oIE = CreateObject("InternetExplorer.Application")
oIE.Navigate("about:blank")
oIE.document.parentwindow.clipboardData.SetData "text", CurrCellContent
oIE.Quit
'Now is the content of the cell in the clipboard

Let us know your results.

Cheers
Stefan

Share
10 |10000 characters needed characters left characters exceeded