I am using Excel 2003. I am trying to use a macro to access an ODBC data source in our accounting program. (MS Navision attain 3.6). The financial software comes with a C/ODBC driver and sample office 97 spread sheet that uses the Excel XLODBC addin to retreive data directly from the financials. I want to do this however using Excel 2003. Unfortunately Microsoft have discontinued the addin. The VBA help says to use the MS Activex data library instead (ADO). It doesent privide any examples or help in making the transition.. I am trying to findout the correct functions to use in the ADO library and how to use them to replace the following XLODBC functions. I have attached the full sample macro code with my comments as I traced the macro functionality.
XLODBC functions to replace -:
SQLOpen()
SQLError()
SQLExecQuery()
SQLRetrieve()
SQLClose()
snipits from the macro
SIZE="1"][/SIZE]
SQLConnectionID = SQLOpen("DSN=Sample C/ODBC 32 bit;Option=Integer;Decimal=Decimal",
Range("ErrorSheet!$D$1"), 2)
Range("ErrorSheet!$A$1..$C$10") = SQLError()
SQLExecQuery _
connectionNum:=SQLConnectionID, _
queryText:="SELECT ""No."", ""Name"", ""Net Change"" FROM ""G/L Account"" WHERE (""Account Type"" = 0)" + _
"AND (""Date Filter"" = '.." + Range("Ratios!$B$1") + "')" + _
"AND (""Department Filter"" = '" + Range("Ratios!$B$2") + "')"+ _ "AND (""Project Filter"" = '" + Range("Ratios!$B$3") + "')" + _
"ORDER BY ""No."" "
SQLClose connectionNum:=SQLConnectionID
Thanks for any pointers
Mike Drummond
Bookmarks