Am I asking VBA via ADO too much here?
No, but there may be a terminology gap if you are used to using SQL CURSORS
etc.
In ADO you would typically
a. open a Connection
b. open a RecordSet by specifying a COnnection, a piece of SQL, and a
couple of other parameters
The RecordSet is in effect a set of rows. You can step through the rows
using the Recordset's .MoveFirst, .MoveNext methods and so on. You can then
get the values of columns in the "current" row via the Fields collection of
the Recordset object, e.g.
myVBAvariablename = objRecordSet.Fields("mycolumnname").Value
Here's an example of a sinmple piece of ADO code - sorry, there are lots of
red herrings in here but I don't have anything simpler to hand. This code is
intended to do a roll-your-own Word mailmerge to email using addresses from
an Excel worksheet.
Sub SendWithXLAddresses()
Const strMergeTemplateFolder = "amergetemplate"
Const strXLWorkbookFullname = "c:\xlfiles\eaddresses.xls"
Const strEAddressColumn = "Emailaddress"
Const strQuery = "SELECT " & strEAddressColumn & " FROM [eaddr$]"
Dim objMailItem As Outlook.MailItem
Dim objConnection As ADODB.Connection
Dim objRecordset As ADODB.Recordset
Set objConnection = New ADODB.Connection
Set objRecordset = New ADODB.Recordset
' Specify Excel 8.0 by using the Extended Properties
' property, and then open the Excel file specified by
' strDBPath. This should work for Excel 97 and later
With objConnection
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties") = "Excel 8.0"
.Open strXLWorkbookFullname
With objRecordset
.Open _
Source:=strQuery, _
ActiveConnection:=objConnection, _
CursorType:=adOpenDynamic, _
LockType:=adLockReadOnly
.MoveFirst
While Not .EOF
Set objMailItem =
Outlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Parent.Folders(strMergeTemplateFolder).Items(1).Copy
With objMailItem
.To = objRecordset.Fields(strEAddressColumn).Value
.Send
End With
Set objMailItem = Nothing
.MoveNext
Wend
.Close ' the recordset
End With
.Close ' the connection/workbook
End With
Set objRecordset = Nothing
Set objConnection = Nothing
End Sub