Remarks

The ODSOColumns collection includes all the data fields in a mail merge data source (for example, Name, Address, and City).

You cannot add fields to the ODSOColumns collection. All data fields in a data source are automatically included in the ODSOColumns collection.

Use (), where is the data field name or index number, to return a single ODSOColumnobject. The index number represents the position of the data field in the mail merge data source.

Example
This example retrieves the name and value of the first field of the first record in the data source attached to the active publication.

Visual Basic for Applications
Sub GetDataFromSource() Dim appOffice As OfficeDataSourceObject Set appOffice = Application.OfficeDataSourceObject appOffice.Open bstrConnect:="DRIVER=SQL Server;SERVER=ServerName;" & _ "UID=user;PWD=;DATABASE=Northwind", bstrTable:="Employees" With appOffice.Columns MsgBox "Field Name: " & .Item(1).Name & vbLf & _ "Value: " & .Item(1).Value End With End Sub

See also:

index index