Creating a Data-Bound Customized Word Document with VSTO

We can create a similar data-bound document in Word using bookmarks rather than named ranges and a data grid rather than an Excel List object. Create a new Word document project and again add the Northwind database as a data source to the Data Sources pane. Visual Studio should remember the connection string from last time, so you will not need to configure it again.

Figure 17-11. A data-bound master-detail Word document in the designer.

Unfortunately, in this version of VSTO, there is no way to bind a data table to a Word table as you can with an Excel list object.

When we build and run the customized Word document, again we have a master-detail view of a data table running in Word without writing a single line of code.

Figure 17-12. The master-detail view at runtime.

Категории