When using Word 2007 MailMerge with an Excel 2007 (xlsx) as a datasource, the .XLSX file is locked and cannot even be copied using Windows Explorer. It is possible to connect to the Excel file as a datasource (using Visual Studio 2008 and .NET 3.5) but it is not possible to use the Office automation or similar third party components.
We need to directly access data inside the Excel file while it is being used by Word 2007 for mail merge and not by using OleDB. Approaches we thought of:
- Using the Windows API to unlock the XLSX file (not sure how to do it and if it is safe).
- Using the Word API to unbind the file as a data source, performing the needed tasks and bind it again (complicated and error prone).
Any thoughts or code samples on a working solution would be much appreciated.