VBA and SAS IOM - applying formats

Sample code (and tips) for applying SAS Formats to data before pulling into excel:

Dim obConnection As New ADODB.Connection
Dim obRecordSet As New ADODB.Recordset

‘workspace (ws) object previously defined
obConnection.Open “provider=sas.iomprovider.1; Data Source=iom-id://” + ws.UniqueIdentifier

‘need to set the connection before the format property can be applied
obRecordSet.ActiveConnection = obConnection

‘use “+ALL” to get both formatted AND unformatted values
obRecordSet.Properties(“SAS Formats”) = ALL

’ the second parameter below has to be EMPTY
obRecordSet.Open sasTable, , adOpenStatic, adLockReadOnly, ADODB.adCmdTableDirect