cancel
Showing results for 
Search instead for 
Did you mean: 

Copying second level Container text - Sendkeys?

former_member478709
Discoverer
0 Kudos

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

stefan_schnell
Active Contributor
0 Kudos

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