cancel
Showing results for 
Search instead for 
Did you mean: 

How to copy the value in SAP and paste in the empty field

Sub Exe_VL01N()
Dim Application, SapGuiAuto, Connection, session, WScript
Dim x As Integer
Dim qtd As String

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

For x = 0 To 1041
qtd = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV50A:1104/tblSAPMV50ATC_LIPS_PICK/ctxtLIPS-LGORT[3," & x & "]").Text
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV50A:1104/tblSAPMV50ATC_LIPS_PICK/ctxtLIPS-LGORT[5," & x & "]").Text = qtd
session.findById("wnd[0]").sendVKey 0
Next x

Or maybe

For x = 0 To 1041
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV50A:1104/tblSAPMV50ATC_LIPS_PICK/ctxtLIPS-LGORT[5," & x & "]").Text = session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\02/ssubSUBSCREEN_BODY:SAPMV50A:1104/tblSAPMV50ATC_LIPS_PICK/ctxtLIPS-LGORT[3," & x & "]").Text
session.findById("wnd[0]").sendVKey 0
Next x

End Sub


Sandra_Rossi
Active Contributor

"how to make it work" is not a valid question if you don't provide any other information.

daniel_mccollum
Active Contributor

If I had to guess you have For x=0 To 1041 & the gui doesnt know a field exists if it isnt paged in, you likely have to add a page down event after you run out of visible rows.

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

At first you select the expect cell then..

Ctrl + Y for copy

Ctrl + V for paste

mateuszadamus
Active Contributor
0 Kudos

Hi rbshot

I don't know Portuguese, but it looks to me like you have an incorrect ID somewhere in your code.

If I was in your shoes, I'd make the code as simple as possible, with hardcoded values for the moment, and see if it works. When it does, then I'd add some logic to it, make it more complex, but add only one thing at a time. Execute and look for the error. When error shows, I know my latest change is the reason.

Regards,

Mateusz