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