• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

how to get data from SAP into the excel

Imran Sait

New Member
Hi all,

I need data from SAP to excel using VBA. till now I was able to log into SAP and run the desired transaction I need using excel and VBA now my second biggest Challenge is to export the data I see in SAP into the excel sheet. there are options in SAP to export the data but I need to do it using the VBA. Kindly help me

Regards,
Imran
 
Hi Misra Ji,

I have seen this link before its of no use to me.
PLease see below the VB code I have written so far, but its just takes me to the data I need but now as I said my second biggest chalange is to get that data from SAP back to Excel.

Sub TEST()
'setting the connection with sap:
Dim App, Connection, session As Object
Set SapGuiAuto = GetObject("SAPGUI")
Set App = SapGuiAuto.GetScriptingEngine
Set Connection = App.Children(0)
Set session = Connection.Children(0)



session.findById("wnd[0]").maximize
session.findById("wnd[0]/tbar[0]/okcd").Text = "iw29"
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/tbar[0]/btn[8]").press
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").currentCellColumn = "TEXT"
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").selectedRows = "0"
session.findById("wnd[1]/usr/cntlALV_CONTAINER_1/shellcont/shell").doubleClickCurrentCell
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").setCurrentCell -1, ""
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").SelectAll
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").contextMenu
session.findById("wnd[0]/usr/cntlGRID1/shellcont/shell").selectContextMenuItem "&XXL"
session.findById("wnd[1]/tbar[0]/btn[0]").press

End Sub
 
Hi, Imran Sait!

Even these are Excel forums I think that you'll have more chances at SAP forums, since it's easier to find within them how to extract data from Excel using VBA that finding SAP access at Excel forums. For example, here only people who have access to a SAP installation would be able to test your code, while for people who work with SAP it's much easier to have an Excel copy at a hand.

Regards!
 
Back
Top