Need help for SAP data copy to Excel

enderem

New Member
Joined
Dec 21, 2020
Messages
2
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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,214,520
Messages
6,120,011
Members
448,935
Latest member
ijat

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
Back
Top