Need help for SAP data copy to Excel

enderem

New Member
Joined
Dec 21, 2020
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Dear Sirs,
I have a excel macro for copy of some equipment data in a list to transfer data into SAP ( I change it sometimes ).,,,
And I want use a list, copy the needed data ( such as " ManufPartNo. ") one after the other from the SAP and paste it in list next to the excel data.
Can someone help me with this please ?

Public SapGuiAuto As Object
Public myapp As Object
Public Connection As Object
Public Session As Object
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sub Klasse_hinzufuegen()

Dim Equi As String
Dim Klasse As String

Set SapGuiAuto = GetObject("SAPGUI")
Set myapp = SapGuiAuto.GetScriptingEngine
Set Connection = myapp.Children(0)
Set Session = Connection.Children(0)

On Error GoTo Fehler:

Range("B4").Select

Do While Not IsEmpty(ActiveCell)

Equi = ActiveCell.Text

ActiveCell.Offset(0, 1).Select
Klasse = ActiveCell.Text

Session.findById("wnd[0]").maximize
Session.findById("wnd[0]/usr/ctxtRM63E-EQUNR").Text = Equi
Session.findById("wnd[0]/usr/ctxtRM63E-EQUNR").caretPosition = 9
Session.findById("wnd[0]").sendVKey 0
Session.findById("wnd[0]/usr/tabsTABSTRIP/tabpT\02").Select
Session.findById("wnd[0]/usr/tabsTABSTRIP/tabpT\02/ssubSUB_DATA:SAPLITO0:0102/subSUB_0102A:SAPLITO0:1050/txtITOB-MSGRP").Text = Klasse
Session.findById("wnd[0]/usr/tabsTABSTRIP/tabpT\02/ssubSUB_DATA:SAPLITO0:0102/subSUB_0102A:SAPLITO0:1050/txtITOB-MSGRP").SetFocus
Session.findById("wnd[0]/usr/tabsTABSTRIP/tabpT\02/ssubSUB_DATA:SAPLITO0:0102/subSUB_0102A:SAPLITO0:1050/txtITOB-MSGRP").caretPosition = 12
Session.findById("wnd[0]/tbar[0]/btn[11]").press
Session.findById("wnd[0]").sendVKey 0

Session.findById("wnd[0]/tbar[0]/btn[3]").press
Session.findById("wnd[0]/tbar[0]/btn[11]").press

ActiveCell.Offset(1, -1).Select

Loop

Exit Sub

Fehler:

MsgBox "Error !"

End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,480
Messages
5,770,337
Members
425,612
Latest member
martinijr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top