The second time the Add method is used the DataConnection object previously created is passed as the parameter to the Add method. This creates another DataRecordset from the same data in ORGDATA.xls. Set vsoDataRecordsetTwo = ActiveDocument.DataRecordsets.Add( _ vsoDataRecordset.DataConnection.ID, _ strCommand, 0, "Org Data") Tip: DataRecordsets.AddFromConnectionFile Creating a DataRecordset from an Office Database Connection file (.odc) is done with the AddFromConnectionFile method of the DataRecordsets object. If an .odc file exists pass the path of the .odc file in the parameter of the method similar to the code presented below. Public Sub AddFromConnectionFile_Example() 'Create a DataRecordset from an .odc file using the 'AddFromConnectionFile method Dim strFile As String Dim strName As String Dim vsoDataRecordset As Visio.DataRecordset strFile = "C:\Documents and Settings\System Admin\My Documents\" & _ "My Data Sources\Northwind Employees.odc"
The second time the Add method is used the DataConnection object previously created is passed as the parameter to the Add method. This creates another DataRecordset from the same data in ORGDATA.xls. Set vsoDataRecordsetTwo = ActiveDocument.DataRecordsets.Add( _ vsoDataRecordset.DataConnection.ID, _ strCommand, 0, "Org Data") Tip: DataRecordsets.AddFromConnectionFile Creating a DataRecordset from an Office Database Connection file (.odc) is done with the AddFromConnectionFile method of the DataRecordsets object. If an .odc file exists pass the path of the .odc file in the parameter of the method similar to the code presented below. Public Sub AddFromConnectionFile_Example() 'Create a DataRecordset from an .odc file using the 'AddFromConnectionFile method Dim strFile As String Dim strName As String Dim vsoDataRecordset As Visio.DataRecordset strFile = "C:\Documents and Settings\System Admin\My Documents\" & _ "My Data Sources\Northwind Employees.odc"
Visio%202010%20Developer%20Training%2003%20-%20Programming%20with%20the%20Visio%20Object%20Model.docx