Skip to Content
author's profile photo Former Member
Former Member

Logon to SAP from Excel VBA script

Hello all,

I'm trying to login to SAP from an Excel spreadsheet macro

Here's what I tried, but I'm not getting connected. Can anyone advise me or point me to a link where I can learn some more.

Thanks

Sub ed_baker_login()
'Declaration
'
Dim objBAPIControl As Object 'Function Control (Collective object)
Dim sapConnection As Object 'Connection object
Set objBAPIControl = CreateObject("SAP.Functions")
Set sapConnection = objBAPIControl.Connection

sapConnection.client = "100"
sapConnection.user = "ebaker"
sapConnection.Language = "EN"
sapConnection.hostname = "Thermo"
sapConnection.Password = "ladeeladee" 'Fake password
sapConnection.SystemNumber = "4"
sapConnection.Destination = "DE1"
sapConnection.logon
If sapConnection.logon(1, True) <> True Then
  MsgBox "No connection to R/3!"
  Exit Sub 'End program
End If

End Sub

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 18, 2009 at 05:43 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 18, 2009 at 08:34 AM

    Hello all,

    I found the answer to my problem.

    I had to add the identification of my login pad value. Once I added this, the login went fine.

    sapConnection.System = "03A. DE1 - ECC 6.0 Development"

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.