cancel
Showing results for 
Search instead for 
Did you mean: 

Logon from VBA to R3

Former Member
0 Kudos

I have following code to connect from VBA to R3

If I use SilentLogon = True, It will be fail.

If I use SilentLogon = False, logon screen will popup, directly click logon will be fail too.

If I use SilentLogon = False, logon screen will popup and I select the existing system that I have, fill all the same information in this code and logon, the connection run successfully.

In this situation where I'm wrong ?

Can I debug to see which parameter I typed wrong ?

Thank you.

Halomoan


Sub connectR3()

Set LogonControl = CreateObject("SAP.LogonControl.1")
Set R3Connection = LogonControl.NewConnection
R3Connection.Client = "130"
R3Connection.ApplicationServer = "10.10.6.10"
R3Connection.Language = "EN"
R3Connection.User = "user1"
R3Connection.Password = "tiger"
R3Connection.System = "00"

SilentLogon = True


retcd = R3Connection.Logon(0, SilentLogon)
If retcd <> True Then
   MsgBox "Logon Failed"
else
  Msgbox "Logon Success"
  R3Connection.Logoff
End if
End Sub

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

too much to think about, just use this:

Set FunctionCtrl = CreateObject("SAP.Functions")

Set SapConnection = FunctionCtrl.Connection

SapConnection.client = "<Client>"

SapConnection.user = "<logon user>"

SapConnection.password = "<Logon Password>"

SapConnection.language = "EN"

SapConnection.HostName = "<hostanme>"

SapConnection.SystemNumber = "<SySnr>"

If Not SapConnection.Logon(0, True) Then

msgbox ("not Connected")

else

msgbox ("connected")

End If

SapConnection.logoff

Former Member
0 Kudos

Hi Andreas

Thank you for your answer.

Point is assigned.

Halomoan

Answers (0)