Skip to Content
Former Member
Apr 20, 2011 at 10:26 PM

Connecting SAP.BAPI in VBA - Connection Problem


Hi there,

I'm trying to develop some code to let an access database (2010) I'm working on pull data from SAP. I've been working through all the coding examples on the web, I even have a nice big book full of even more wonderful examples, but I seem to be suck just past the starting blocks.

I can sucessfully connect to SAP using the SAP.LogonControl, and end up creating a valid connection called msapConn.


returns 1, and I can query things like .System and .ApplicationServer and get valid responses.

I then go on to define a msapBapi object as:

set msapBapi = CreateObject("SAP.BAPI.1")

to which all of the coding examples I have read say I should be able to define:

set msapBapi.Connection = msapConn

But all I get is a "Bad variant type" error.

Anyone able to point me in the right direction?

(P.S. I have wdobapi.ocx and wdtlog.ocx as references for the project)