Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get ADODB to work with Excel for Mac 2011?

Tags:

macos

excel

vba

ado

I can not seem to get my Excel workbook (using ADODB) to work with Excel Mac 2011. I am using ADODB code. Are there add-ins available? Even from a third-party? Has anyone gotten this to work?

like image 872
n8gard Avatar asked Mar 14 '12 17:03

n8gard


People also ask

What is VBA Adodb?

An ADODB Recordset in VBA is a storage item: you can store all kinds of different things in it: numbers, texts, dates. An ADODB Recordset is a database that you can design, fill and edit completely in the working memory. VBA has several other options for storing data: - a dictionary.


1 Answers

ADODB is NOT supported in Mac Excel 2011, but ODBC works in conjunction with a 3rd party driver.

I got my ODBC drivers from ActualTech. Download and install their program and you'll have the necessary drivers for connecting to SQL servers and databases (Free to try, $35 to purchase).

The following code creates a connection to a mySQL database, and returns information from the database into Cell A1:

Dim connstring as String
Dim sqlstring as String

connstring = "ODBC;DRIVER={Actual Open Source Databases};" _
& "SERVER=<server_location>;DATABASE=<database>;" _
& "UID=<userID>;PWD=<password>;Port=3306"
sqlstring = "select * from <database_table>"

With ActiveSheet.QueryTables.Add(Connection:=connstring, Destination:=Range("A1"), Sql:=sqlstring)
  .BackgroundQuery = False
  .Refresh
End With
like image 147
thedanotto Avatar answered Sep 30 '22 17:09

thedanotto