ConnectString 属性
优质
小牛编辑
127浏览
2023-12-01
返回或设置一个 String 类型,表示与指定邮件合并数据源的连接。可读写。
expression.ConnectString
expression 必需。该表达式返回“应用于”列表中的对象之一。
示例
本示例检查连接字符串是否包含字符串 ODSOOutlook,并显示相应的消息。
Sub VerifyCorrectDataSource()
Dim appOffice As OfficeDataSourceObject
Set appOffice = Application.OfficeDataSourceObject
appOffice.Open bstrConnect:="DRIVER=SQL Server;SERVER=ServerName;" & _
"UID=user;PWD=;DATABASE=Northwind", bstrTable:="Employees"
If InStr(appOffice.ConnectString, "ODSOOutlook") > 0 Then
MsgBox "Your Outlook address book is used as the data source."
Else
MsgBox "Your Outlook address book is not used as the data source."
End If
End Sub