Hi All,
I am trying to extract sale text from MM03 for a few items.
I am able to extract it; but the problem is that if the sales text is in different lines that is it has more than 1 line one below the other as content, I am getting everything in one line in excel and not as in SAP.
Can someone help
Sub salestext()
Dim t As String
Set SapGuiAuto = GetObject("SAPGUI")
Set App = SapGuiAuto.GetScriptingEngine
Set Connection = App.Children(0)
Set session = Connection.Children(0)
For i = 2 To Sheets("Data").Range("A1048576").End(xlUp).Row
session.findById("wnd[0]").maximize session.findById("wnd[0]/tbar[0]/okcd").Text = "mm03"
session.findById("wnd[0]").sendVKey 0 session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").Text = Sheets("Data").Range("A" & i)
session.findById("wnd[0]").sendVKey 0 session.findById("wnd[1]/usr/ctxtRMMG1-WERKS").Text = "3601"
session.findById("wnd[1]/tbar[0]/btn[0]").press On Error GoTo skip session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP08").Select
session.findById("wnd[1]/usr/ctxtRMMG1-WERKS").Text = "3601"
session.findById("wnd[1]/usr/ctxtRMMG1-VTWEG").Text = "00"
session.findById("wnd[1]/usr/ctxtRMMG1-VTWEG").SetFocus
session.findById("wnd[1]/usr/ctxtRMMG1-VTWEG").caretPosition = 2
session.findById("wnd[1]/tbar[0]/btn[0]").press
t = session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP08/ssubTABFRA1:SAPLMGMM:2010/subSUB2:SAPLMGD1:2121/cntlLONGTEXT_VERTRIEBS/shellcont/shell").Text
session.findById("wnd[0]/tbar[0]/btn[3]").press
Sheets("Data").Cells(i, 3) = t
skip:
session.findById("wnd[0]/tbar[0]/btn[3]").press
Next
End Sub .