Skip to Content

Connect to SAP using Excel, run query, export back to Excel

Hello all,

First post here, i've had a look through the forums to see if my query has already been answered but i can't seem to find a thread for it - so here goes.

I use Excel through Office 365, i also use SAP NetWeaver (SAP GUI for Windows)

What i'd like to do is have some code in VBA to enable the following:

Open SAP

Log in using my own credentials

Open a certain transaction

Choose a layout

Define the dates

Execute

Export to Excel

From there I can get Excel to do what I need it to, its just the parts in bold & Italic that I'm really struggling with.

Is there anyone here who is willing to hand hold a little to get me up and running? (would be massively appreciated)

Regards

Rich

**Edit**

I've tried the below but it fails:

Sub sap() Application.ScreenUpdating = False Dim sap As Object Dim conn As Object Set sap = CreateObject("SAP.Functions") Set conn = sap.Connection conn.System = "SYSTEM" conn.client = "000 " conn.user = "user" conn.Password = "pass" conn.Language = "EN" If conn.logon(0, False) <> True Then MsgBox "Logon to the SAP system is not possible", vbOKOnly, "Comment" Else End If Application.ScreenUpdating = True End Sub

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • May 09 at 04:17 PM

    Hi

    Please refer below link

    https://blogs.sap.com/2014/08/31/interactive-and-dynamic-excel-vba-template-sap-gui-scripting/

    I have used to do things with excel and it is working for me perfectly. If you want to get my help drop my inbox.

    Regards

    Mahe

    Add comment
    10|10000 characters needed characters exceeded

  • May 09 at 01:15 PM

    Hi Galvin.

    Could you share little bit in detail about your SAP system (like ECC or BI)?

    Regards

    SS

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Sriram,

      Thanks for the interest - but for clarity, what do you require?

      Please excuse me, i'm far from a super / power SAP user - however, i'll take a guess at what you're asking:

      SAP ECC

      DBSL Version - 749.05

      Product - SAP NETWEAVER

      RELEASE - 7.5

      Does that help?

      Regards

      Rich

  • May 09 at 04:04 PM

    Hi Sriram,

    Thanks for the interest - but for clarity, what do you require?

    Please excuse me, i'm far from a super / power SAP user - however, i'll take a guess at what you're asking:

    SAP ECC

    DBSL Version - 749.05

    Product - SAP NETWEAVER

    RELEASE - 7.5

    Does that help?

    Regards

    Rich

    Add comment
    10|10000 characters needed characters exceeded

  • May 17 at 08:02 AM

    Hello Rich,

    perhaps this could help:

    https://www.youtube.com/watch?v=05kOqmxcPi8

    It's called: "SAP GUI Scripting - Extract SAP report data to Excel"

    Regards, Michael

    Add comment
    10|10000 characters needed characters exceeded