Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Gets or sets a String that represents the name of the attached data source. Read/write.
Syntax
expression.DataSource
expression A variable that represents an OfficeDataSourceObject object.
Example
The following example sets the name of the data source if the name is blank.
Sub SetAndReturnDataSourceName()
Dim appOffice As OfficeDataSourceObject
Set appOffice = Application.OfficeDataSourceObject
With appOffice
.Open bstrConnect:="DRIVER=SQL Server;SERVER=ServerName;" & _
"UID=user;PWD=;DATABASE=Northwind", bstrTable:="Employees"
If .DataSource = "" Then
.DataSource = "Northwind"
MsgBox .DataSource
End If
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.