I would like to create a silent SAP.FUNCTIONS connection to SAP using Excel VBA. Whenever I set the password, the connection object gets trashed. Is this even possible?
Sub Connect_to_SAP()
Dim myConnection As Object
Set myConnection = CreateObject("SAP.Functions.unicode")
With myConnection
.Connection.System = "SID" 'Systemname
.Connection.client = "800" 'Client
.Connection.APPLICATIONSERVER = "192.111.222.333"
.Connection.user = "MYUSERNAME" 'User
.Connection.Password = "MYPASSWORD" ' <=== after that, myConnection.connection object is trashed
.Connection.Language = "EN" 'Language
.Connection.systemnumber = "00" 'Systemnumber
End With
'Establish connection.
If myConnection.Connection.logon(0, True) <> True Then Exit Sub
'System Logoff
myConnection.Connection.LOGOFF
End Sub
NB: This is under SAPGUI 7.6 pl4. We are connecting to SAP with 7.60 pl6 using the MYSAPSSO ticket (portal SSO).
SAP.Functions
instead ofSAP.LogonControl
. Anyway, could you try by removing the.Unicode
part, just in case? If it doesn't work, and if you use a 64 bits version of Office, could you try to delegate the 32 bits version of SAP.Functions(.Unicode) to 64 bits by editing the Windows registry as explained here? – Sandra Rossi