5 Replies Latest reply: Mar 7, 2013 4:51 PM by 995568 RSS

    Programmatically adding ODBC driver using VBA

    979641
      Hi -
      I have a VBA macro that connects to an Oracle db and pulls data into Excel using ADO. It uses the Provider 'OraOLEDB.Oracle.1'. The macro runs fine on my system. I am now giving this macro to others in my organization so they can also use it. However, the other machines do not have Oracle client loaded on their systems. The macro stops at the Connection.Open line because it does not recognize "OraOLEDB.Oracle.1"

      So, here are my questions:
      1. What drivers do I need to provide to the other users so that the macro can run?
      2. Does the other system have to have Oracle client loaded or can I just load the driver software (OraOLEDB.Oracle.1)?
      3. Can I programmatically check if the other system has the driver and if not, programmatically load the driver?
      4. Is it possible to attach the OraOLEDB.Oracle.1 code as a file and then have the VBA code install it if needed?

      My VBA code looks like this:

      Set Connection = New ADODB.Connection
      Connection.ConnectionTimeout = 20
      Connection.CommandTimeout = 15

      Cnct = "*Provider=OraOLEDB.Oracle.1*; Data Source=PDW; User Id=<user_id>; Password=<password>"
      Connection.Open ConnectionString:=Cnct

      Here is a list of the reference libraries used in this VBA project:
      Reference Description
      Visual Basic For Applications
      Microsoft Excel 14.0 Object Library
      Microsoft Forms 2.0 Object Library
      Microsoft Visual Basic for Applications Extensibility 5.3
      Microsoft Office 14.0 Object Library
      OLE Automation
      Microsoft ActiveX Data Objects 2.8 Library
      Microsoft Script Control 1.0
      Microsoft Scripting Runtime
      Microsoft ActiveX Data Objects Recordset 2.8 Library

      Thanks for your guidance.
      Gary
        • 1. Re: Programmatically adding ODBC driver using VBA
          Tridus
          OraOLEDB is part of the Oracle client and relies on the client, so yes you'll need to have the Oracle client installed. I don't really know enough (aka: anything) about VBA to answer the other questions, sorry.
          • 2. Re: Programmatically adding ODBC driver using VBA
            979641
            Tridus - thanks for your reply. I was concerned that Oracle Client would have to be downloaded to each machine that wants to run this macro.

            What is OraOLEDB? Is it a single file? Is it a library of calls? What exactly is it?
            • 3. Re: Programmatically adding ODBC driver using VBA
              orafad
              Why do you want to add "ODBC driver" when you are using OraOLEDB?

              How do you plan to solve other requirements such as "Visual Basic For Applications"?

              Perhaps you could ship Instant Client with your Excel application?
              Then use Windows included interface libraries "for Oracle", or Instant Client ODBC, or include Xcopy deployment of data provider for OLE DB (OraOLEDB) from ODAC (builds on Instant Client).

              See:
              http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
              http://www.oracle.com/technetwork/database/windows/downloads/index-101290.html (32-bit)
              http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html (64-bit)
              • 4. Re: Programmatically adding ODBC driver using VBA
                Tridus
                976638 wrote:
                Tridus - thanks for your reply. I was concerned that Oracle Client would have to be downloaded to each machine that wants to run this macro.

                What is OraOLEDB? Is it a single file? Is it a library of calls? What exactly is it?
                OraOLEDB is Oracle's OLE DB database provider. It's kind of like the ODBC driver except for OLE DB, which is a different interface. I don't know the details of how many files it is, but it's included in the Oracle driver for Windows.
                • 5. Re: Programmatically adding ODBC driver using VBA
                  995568
                  Hello
                  Would you be so kind to share your vba code to connect to Oracle Db thru odbc?

                  Thanks