View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
AB[_2_] AB[_2_] is offline
external usenet poster
 
Posts: 236
Default Accessing the Data Connection Strings and Command Text (SQL) inVB

In excel vba you can code pretty much the same way as in access vba.
If you want to have intellisense and use early bounding - add
refference to dao library (in vbe ToolsRefferences and then check the
most recent DAO lib taht you have or whichever want to use) and off
you go.

google for:
set DAO.Database object from excel
and will get loads of feeds.

On Apr 30, 2:45*pm, MChrist wrote:
I have a number of Excel files that have data connections to various sources,
and I want to be able to read the data connection strings and command text
(SQL) using VBA.

In Access this would be easy to do, creating a database object, and looking
at the QueryDefs. *Is there something similar in Excel?

If someone could point me to an on-line reference or provide a code like the
one below, that would be great.

Thank you.

Mark

Private Sub Test()

* Dim strMsg As String

* Dim db As DAO.Database
* Dim qds As DAO.QueryDefs
* Dim qd As DAO.QueryDef

* Set db = currentdb()
* Set qds = db.QueryDefs

* For Each qd In qds

* * Debug.Print qd.Connect & vbTab & qd.Sql

* Next

End Sub