Hi this is a small query in regards to copying info from SAP to Excel.
My current script query is: -
Sub GetData()
If Not IsObject(anApplication) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set anApplication = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = anApplication.Children(0)
End If
If Not IsObject(session) Then
Set session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject session, "on"
WScript.ConnectObject Application, "on"
End If
session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "mm60"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtMS_MATNR-LOW").Text = Sheets("Material List").Cells(2, 8).Value
session.findById("wnd[0]/usr/ctxtMS_WERKS-LOW").Text = Sheets("Material List").Cells(2, 9).Value
session.findById("wnd[0]/usr/ctxtMS_WERKS-LOW").SetFocus
session.findById("wnd[0]/usr/ctxtMS_WERKS-LOW").caretPosition = 4
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").currentCellColumn = "ERNAM"
Set coll1 = Application.createGuiCollection
coll1.Add "0,BWTAR"
coll1.Add "0,KTEXT"
coll1.Add "0,LAEDA"
coll1.Add "0,MTART"
coll1.Add "0,MATKL"
coll1.Add "0,MEINS"
coll1.Add "0,EKGRP"
coll1.Add "0,MAABC"
coll1.Add "0,DISMM"
coll1.Add "0,BKLAS"
coll1.Add "0,VPRSV"
coll1.Add "0,PREIS"
coll1.Add "0,WAERS"
coll1.Add "0,PEINH"
coll1.Add "0,ERNAM"
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectedCells = coll1
Set coll1 = Nothing
End Sub
Its not working outside SAP which I probably expected so the VBA for the copy and paste into an existing Excel workbook would help me trendously.
Thanks
Michael