How to Connect Access Database to Word via VSTO and VB.NET
Question details
The user wants to retrieve data from an Access database, display it in Word controls, and generate or print documents using a VSTO Word solution in VB.NET.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Developing a VSTO Word add-in or document-level solution that needs to dynamically load data from an Access database into document controls.
- Observed behavior
- Standard mail merge displays unwanted query dialog prompts, leading the user to seek a programmatic VB.NET solution using design-time and runtime data binding.
Ensure you have Visual Studio installed with the 'Office/SharePoint development' workload, and verify that your target Access database (.accdb or .mdb) is accessible and not exclusively locked.
Programmatic Data Binding via VSTO and VB.NET
Use a typed DataSet, TableAdapter, and BindingSource to securely retrieve and display data without triggering mail merge prompts.
By utilizing VB.NET data components at both design time and runtime, you can fully automate how Word interacts with an Access database. This approach bypasses the limitations of the native mail merge feature, such as unexpected SQL query prompts.
In Visual Studio, open the Data Sources window and add a new Data Source. Select 'Database', then 'Dataset', and establish a connection to your Access database.
Configure the connection to generate a typed DataSet and a TableAdapter in your VB.NET project, which will handle the underlying SQL queries and data structure.
Drag tables or fields from the Data Sources window directly onto your VSTO document or Action Pane. This automatically creates a BindingSource linking your controls to the dataset.
In your VB.NET code (e.g., the Document_Startup event), call the TableAdapter's 'Fill' or 'GetData' method to populate the dataset with the latest records from Access before printing or displaying the document.

Using Access VBA Automation
Use Access VBA to push data into a Word document if building a full VSTO VB.NET solution is not strictly required.
Looking for a Lightweight Office Suite? Try WPS Office
Developing complex VSTO solutions can be highly resource-intensive. If you are looking for a fast, highly compatible, and free alternative to Microsoft Office for your daily document processing and built-in mail merge tasks, WPS Office provides excellent performance without the heavy overhead.
- 1. Download the Installer: Visit the official WPS Office website and download the free installation package.
- 2. Install WPS Office: Run the installer and follow the quick on-screen instructions to set up the software.
- 3. Open Your Documents: Launch WPS Writer and open your existing .docx files directly, maintaining full layout and formatting compatibility.

Frequently Asked Questions
Why does Word mail merge display a query prompt when connecting to Access?
This happens due to Office security settings checking OLE DB or DDE connections before executing SQL commands. Using programmatic data access via VSTO or VBA bypasses these interactive user prompts entirely.
What is the difference between a DataSet and a TableAdapter in VB.NET?
A DataSet is an in-memory cache of data retrieved from the database, while a TableAdapter provides the communication link, executing SQL queries or stored procedures to fetch the data into the DataSet and send updates back to Access.
Do end-users need Microsoft Access installed to run my VSTO Word solution?
Users do not need the full Microsoft Access application installed to run the solution. However, they must have the correct Microsoft Access Database Engine (ACE OLEDB provider) installed on their machine to allow the VSTO add-in to read .accdb or .mdb files.




