Skip to Content
Former Member
Mar 18, 2009 at 12:25 AM

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.


Sub ed_baker_login()
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"
If sapConnection.logon(1, True) <> True Then
  MsgBox "No connection to R/3!"
  Exit Sub 'End program
End If

End Sub