I created a short script in SAP by recording my steps, to generate the report for one material number, but I pasted this material from my hand - line 24. I would like to use excel in the future for it. I mean I would like the data to be copied from a specific Excel cell to SAP.
I am not sure how to connect SAP with Excel, or how to retrieve data from specific cells. If you have any example of code it would be nice if you share it with me
Request clarification before answering.
Hi,
The code should be as follows:
Sub code()
Dim sap As Object
Dim conn As Object
Set sap = CreateObject("SAP.Functions")
Set conn = sap.Connection
Set SapGuiAuto = GetObject("SAPGUI")
Set SAPApp = SapGuiAuto.GetScriptingEngine
Set SAPCon = SAPApp.Children(0)
Set session = SAPCon.Children(0)
Set Macro1 = Workbooks("Configuration.xlsb")
Application.ScreenUpdating = False
Macro1.Activate
Sheets("Class").Select
On Error Resume Next
I = 2
Do While ActiveSheet.Range("a" & I) <> ""
Application.DisplayAlerts = False
-->your SAP script goes over here. you need to refer a cell instead of single material number in the code.
Application.DisplayAlerts = True
I = I + 1
Macro1.Activate
Sheets("Class").Select
Application.ScreenUpdating = True
'DoEvents
Loop
End Sub
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 12 | |
| 12 | |
| 7 | |
| 7 | |
| 5 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.