OfficeDataSourceObject.Columns property (Office)
Gets an ODSOColumns object that represents the fields in a data source. Read-only.
Syntax
expression.Columns
expression A variable that represents an OfficeDataSourceObject object.
Example
The following example displays the field names in the data source attached to the active publication.
Sub ShowFieldNames()
Dim appOffice As OfficeDataSourceObject
Dim intCount As Integer
Set appOffice = Application.OfficeDataSourceObject
appOffice.Open bstrConnect:="DRIVER=SQL Server;SERVER=ServerName;" & _
"UID=user;PWD=;DATABASE=Northwind", bstrTable:="Employees"
With appOffice.Columns
For intCount = 1 To .Count
MsgBox "Field Name: " & .Item(intCount).Name
Next
End With
End Sub
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for