【发布时间】:2016-03-15 01:04:39
【问题描述】:
我想在我的 Visio 文档中添加一个 Access 数据库。 MSN 示例显示了连接到 Excel 文档的字符串。我将使用什么来连接 Access DB?
我正在使用:
微软 Visio 2013
Microsoft Access 2013
Microsoft Windows 7 企业版。
数据库位置:
C:\Users\j.Smith\Desktop\access_file.mdb
我的脚本:
Public Sub AddDataRecordset_Example()
Dim strConnection As String
Dim strCommand As String
Dim strOfficePath As String
Dim vsoDataRecordset As Visio.DataRecordset
strOfficePath = Visio.Application.Path
strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;" _
& "User ID=Admin;" _
& "Data Source=" + strOfficePath + "SAMPLES\1033\ORGDATA.XLS;" _
& "Mode=Read;" _
& "Extended Properties=""HDR=YES;IMEX=1;MaxScanRows=0;Excel 12.0;"";" _
& "Jet OLEDB:Engine Type=34;"
strCommand = "SELECT * FROM [Sheet1$]"
Set vsoDataRecordset = ActiveDocument.DataRecordsets.Add(strConnection, strCommand, 0, "Org Data")
End Sub
【问题讨论】: